The email field, when left-blank, will report something like "must be an email address". I would expect the required rule to be checked first, so that the message would be something like "this field is required".
In my opinion, following rules, email in this case, do not need to be validated, if previous rules, required in this case, already failed. Or if they are, still keep the first error message and display that first. Otherwise one has to flip the order of the rules around. This would be in contrast to the examples in the documentation (e.g. https://typerocket.com/docs/v5/validator/#section-about-validation).
When it comes to validation, I find the order in which the rules are applied unexpected and unintuitive.
Take this for example:
The
email
field, when left-blank, will report something like "must be an email address". I would expect therequired
rule to be checked first, so that the message would be something like "this field is required".As far as I checked in the
Validator
, this is due to the fact, that errors raised by the following rules overwrite previous errors (see https://github.com/TypeRocket/core/blob/main/src/Utility/Validator.php#L532).In my opinion, following rules,
email
in this case, do not need to be validated, if previous rules,required
in this case, already failed. Or if they are, still keep the first error message and display that first. Otherwise one has to flip the order of the rules around. This would be in contrast to the examples in the documentation (e.g. https://typerocket.com/docs/v5/validator/#section-about-validation).