Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (input: Input) => {
if (skipOnEmpty && isEmpty(input)) {
return;
}
const matches = matcher(input);
if (matches) {
return;
}
if (typeof errorContent === 'function') {
return errorContent(input);
}
return errorContent;
};
};
return (input: Input, fields: Fields) => {
const matches = matcher(input, fields);
/*
always mark empty fields valid to match Polaris guidelines
https://polaris.shopify.com/patterns/error-messages#section-form-validation
*/
if (isEmpty(input)) {
return;
}
if (matches) {
return;
}
if (typeof errorContent === 'function') {
return errorContent(toString(input));
}
return errorContent;
};
}