Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const minLength = (name, value, schema) => ({
isValid: is.equal(value.length, schema.minLength) || is.above(value.length, schema.minLength),
errorText: `${name}'s length should be equal or greater than ${schema.minLength}. Current: ${value.length}`
});
export function minLengthHandler(value, schema) {
const isValid = is.above(value.length, schema.minLength);
if (isValid) return;
const errorText = `${NAME_PLACEHOLDER}'s length should be greater than ${schema.minLength}. Current: ${value.length}`;
throwError(value, errorText);
}
export function minHandler(value, schema) {
const isValid = is.above(value * 1, schema.min * 1);
if (isValid) return;
const errorText = `${NAME_PLACEHOLDER} should be greater than ${schema.min}. Current: ${value}`;
throwError(value, errorText);
}
export const min = (name, value, schema) => ({
isValid: is.above(value * 1, schema.min * 1),
errorText: `${name} should be greater than ${schema.min}. Current: ${value}`
});