You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently one can create custom Validators using CustomValidator, where one specifies a predicate and an error message in case the predicate fails. In some cases it would be useful to generate a custom message based on the failed input. Basically indicating more specifically what is wrong with the input-string.
E.g. I have a field for inputting an ipv4 network-prefix, if the first octects are ok, but the last octet is not compatible with the network mask, I want to indicate what the closest valid numbers are for the last octet, instead of just reporting that the input value is not compatible with the provided mask.
Ideas for how this could be solved:
Open up the ValidationResult constructor or add a static factory-method taking the error message as a parameter. This would allow one to create Validators by just implementing Validator (given that there also would be a public way to generate an OK result.
Modify CustomValidator somehow to allow modifying the error message before creating the result. E.g. by providing an optional error-message generator function taking the input value and returning a message.
The text was updated successfully, but these errors were encountered:
Currently one can create custom Validators using CustomValidator, where one specifies a predicate and an error message in case the predicate fails. In some cases it would be useful to generate a custom message based on the failed input. Basically indicating more specifically what is wrong with the input-string.
E.g. I have a field for inputting an ipv4 network-prefix, if the first octects are ok, but the last octet is not compatible with the network mask, I want to indicate what the closest valid numbers are for the last octet, instead of just reporting that the input value is not compatible with the provided mask.
Ideas for how this could be solved:
The text was updated successfully, but these errors were encountered: