Laravel rule validate a field less than or greater than another field

Image for post
Image for post

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!

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!

Written by

Web geek, Self-taught full-stack web developer, Learning Python, Laravel, Vuejs, UX/UI design, Nuclear Physicist PhD

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store