Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
: { hasForbiddenChars: true };
return {
...acc,
[language]: value,
};
}, {});
errors.slug.translations = translationErrors;
}
// validate description
if (MultilineTextInput.isEmpty(formValues.description))
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
description: {},
inventory: {},
price: {},
};
// validate key
// Input elements usually provide a way to check whether it's value is empty
// This is useful to determine whether a required value was not filled out.
if (TextInput.isEmpty(formValues.key)) errors.key.missing = true;
// validate description
if (MultilineTextInput.isEmpty(formValues.description))
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