Skip to content

Commit

Permalink
ADDON-34762: Added SaveValidator function
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhatri-crest committed Mar 16, 2021
1 parent 4fc2337 commit 25ae444
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ import {
parseNumberValidator,
parseRegexRawStr,
parseStringValidator,
parseFunctionRawStr
} from './uccConfigurationValidators';

// Validate provided saveValidator function
export function SaveValidator(validatorFunc, formData) {
const { error, result } = parseFunctionRawStr(validatorFunc);
if (error) {
return { errorMsg: error };
}
let ret = result(formData);
if (typeof ret === 'string') {
return { errorMsg: ret };
}
}

class Validator {
constructor(entities) {
this.entities = JSON.parse(entities);
Expand Down

0 comments on commit 25ae444

Please sign in to comment.