govalidator
govalidator copied to clipboard
Add comparison rules
Comparison rules addded:
- Rule functions have access to the entire form in order to be able to compare one field with another.
- Can be used to add more complex rules such as "field_1 must be greater than field_2" or even "date_start must be before date_end"
- Updated documentation and README to reflect the change
Caveats:
- Breaks backward compatibility. But can be fixed simply by adding the following parameter to all custom rules:
form map[string]interface{}
- Slightly heavier when not using JSON in request since a copy of the form in a
map[string]interface{}
is made.
Coverage increased (+0.5%) to 89.813% when pulling 4890adfc4c1b8b315a222e6a3f4483f0e0aa096a on System-Glitch:features/comparison into a8b0eb43cdf5ec8751b5e5bbfb8d9ac1c96aafae on thedevsaddam:dev.
@thedevsaddam can you approve this PR? :)
@thedevsaddam approve this PR plz, thanks my friend!
Guys, this is a breaking change. To merge the request we have to move to the next major release. Can you consider this issue #26, seems it'll resolve the current PR