govalidator icon indicating copy to clipboard operation
govalidator copied to clipboard

Add comparison rules

Open System-Glitch opened this issue 4 years ago • 4 comments

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.

System-Glitch avatar Sep 30 '19 12:09 System-Glitch

Coverage Status

Coverage increased (+0.5%) to 89.813% when pulling 4890adfc4c1b8b315a222e6a3f4483f0e0aa096a on System-Glitch:features/comparison into a8b0eb43cdf5ec8751b5e5bbfb8d9ac1c96aafae on thedevsaddam:dev.

coveralls avatar Sep 30 '19 12:09 coveralls

@thedevsaddam can you approve this PR? :)

lsfiege avatar Nov 11 '19 20:11 lsfiege

@thedevsaddam approve this PR plz, thanks my friend!

afloresaivo avatar Nov 11 '19 20:11 afloresaivo

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

thedevsaddam avatar Nov 12 '19 07:11 thedevsaddam