In order to validate a field (string , integer or array) under the rule of being less than or greater than another field, there is a simple solution which has been introduced since Laravel 5.6.
The fields can be : string, numeric or array.
Strings, numerics, arrays, and files are evaluated using the same conventions as the
size rule. The two fields must be of the same type.
The validation rules for the case of “less than” are:
The field under validation must be less than the given field.
The field under validation must be less than or equal to the given field.
The rules for the case of “greater than” are:
The field under validation must be greater than the given field.
The field under validation must be greater than or equal to the given field.
Thank you for reading! If you enjoyed this article:
Clap it ! Share it! Follow Me in Medium!
Panjeh — Medium
Read writing from Panjeh on Medium. Physicists PhD, Self-taught web developer #Learning, #laravelphp #Vuejs. Every day…
Also I’d like to hear your opinion on this article. If you have any doubt, question or suggestion please leave a comment below.
Have a very wonderful day!