@shopify/react-form
Version:
Manage React forms tersely and safely-typed with no magic using React hooks
21 lines (19 loc) • 436 B
JavaScript
function runValidation(updateError, state, validators) {
const {
value,
listItem,
siblings
} = state;
const error = validators.map(check => check(value, {
listItem,
siblings
})).filter(value => value != null);
if (error && error.length > 0) {
const [firstError] = error;
updateError(firstError);
return firstError;
}
updateError(undefined);
return undefined;
}
export { runValidation };