Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
errors.description.missing = true;
// validate inventory
if (NumberInput.isEmpty(formValues.inventory)) {
errors.inventory.missing = true;
} else {
// When the value is not empty, we can assume that it is a number
if (formValues.inventory < 0) errors.inventory.negative = true;
if (NumberInput.hasFractionDigits(formValues.inventory))
errors.inventory.fractions = true;
}
// validate price
if (MoneyInput.isEmpty(formValues.price)) {
errors.price.missing = true;
} else if (MoneyInput.isHighPrecision(formValues.price, locale)) {
errors.price.unsupportedHighPrecision = true;
}
// Formik will think there are errors when the object returned as a
// validation result has at least one key. We therefore have to omit
// all empty fields inside the error object.
// When an empty object is returned, formik will assume there were no errors
return omitEmpty(errors);
};
errors.description.missing = true;
// validate inventory
if (NumberInput.isEmpty(formValues.inventory)) {
errors.inventory.missing = true;
} else {
// When the value is not empty, we can assume that it is a number
if (formValues.inventory < 0) errors.inventory.negative = true;
if (NumberInput.hasFractionDigits(formValues.inventory))
errors.inventory.fractions = true;
}
// validate price
if (MoneyInput.isEmpty(formValues.price)) {
errors.price.missing = true;
} else if (MoneyInput.isHighPrecision(formValues.price, locale)) {
errors.price.unsupportedHighPrecision = true;
}
// Formik will think there are errors when the object returned as a
// validation result has at least one key. We therefore have to omit
// all empty fields inside the error object.
// When an empty object is returned, formik will assume there were no errors
return omitEmpty(errors);
};