Skip to content

Commit

Permalink
feat(reschema): add method validateFields
Browse files Browse the repository at this point in the history
  • Loading branch information
medson10 committed Nov 22, 2019
1 parent fc7333f commit 4b712a3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/reschema/src/ReSchema.re
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ module Make = (Lenses: Lenses) => {
->Belt.Option.map(validator => validateField(~validator, ~values, ~i18n));
};

let validateFields = (~fields, ~values, ~i18n, schema: Validation.schema) => {
let Validation.Schema(validators) = schema;

Belt.Array.map(fields, field =>
getFieldValidator(~validators, ~fieldName=field)
)
->Belt.Array.map(validator =>
Belt.Option.map(validator, validator =>
validateField(~validator, ~values, ~i18n)
)
);
};

let validate =
(
~i18n=ReSchemaI18n.default,
Expand Down

0 comments on commit 4b712a3

Please # to comment.