Support validation for custom fields that can block collection saving
A
Adam
I'd like to request a feature that allows custom fields to block collection saving if their validation fails.
Use case:
I've created a custom field which is a text input. Its validation depends on the value of another select field. I use a regex inside the custom input component to validate the value, and display an error using <Field.Error />.
Currently, even when the input is visibly invalid, Strapi still allows the collection to be saved with the wrong value. This defeats the purpose of custom validation.
What I need:
I would like the ability to prevent saving a collection entry when a custom field is invalid.
This could be done by supporting a new prop in the custom field component, for example:
```const Input = forwardRef(
({ attribute, name, onChange, value, validationError }: InputProps, ref) => {```
Where validationError could be:
```{
isSaveBlocker: boolean;
errorMessage: string;
}```
Expected behavior:
If validationError.isSaveBlocker is true, the admin panel should prevent the user from saving the entry.
Optionally, the errorMessage can be shown in a global or contextual warning to explain the issue.