Skip to content

Commit

Permalink
update validateValue func
Browse files Browse the repository at this point in the history
  • Loading branch information
elewis2 committed May 3, 2024
1 parent c4b254c commit db43555
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/services/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,25 @@ const validateValue = (propModel, value, { ignoreMandatory = false }) => {
};

if (Array.isArray(value) && value.length) {
// values could have different class models
value.forEach((val) => {
embeddedModel = schemaDefn.get(val);
embeddedModel = schemaDefn.get(val['@class']);

if (embeddedModel) {
Object.values(schemaDefn.getProperties(embeddedModel)).forEach((subPropModel) => {
Object.values(schemaDefn.getProperties(embeddedModel.name)).forEach((subPropModel) => {
subErrors = valErrorCheck(subPropModel, val, subErrors);
});
}
});
} else {
try {
embeddedModel = schemaDefn.get(value);
embeddedModel = schemaDefn.get(value['@class']);
} catch (err) { } // eslint-disable-line no-empty

if (!embeddedModel) {
return { error: { '@class': { message: 'Required Value' } } };
}

Object.values(schemaDefn.getProperties(embeddedModel)).forEach((subPropModel) => {
Object.values(schemaDefn.getProperties(embeddedModel.name)).forEach((subPropModel) => {
subErrors = valErrorCheck(subPropModel, value, subErrors);
});
}
Expand Down

0 comments on commit db43555

Please sign in to comment.