Best practice
Many of available rule can switch between types and compare data of different types. If you know what type do you expect, then better to set this check.
For example, we expect to get int
, then we set intType
check at the beginning of validation:
If for some reason we want to have number in string type, there is no need to convert it to integer, just add addition validation:
Many of rules can switch type of variable for you, please visit comparable values for more information.Success
Best practice is to set validation as close as you can to your expectations for final data