CSenshi / Validator

Easy-to-use, Highly Configurable Python Data Validator. Inspired by Laravel Validator
https://pypi.org/project/validator/
MIT License
46 stars 23 forks source link

New Rule: Same #61

Closed CSenshi closed 4 years ago

CSenshi commented 4 years ago

Write rule that validates data to be exactly same as given value.

Description: "The given field must match the field under validation"

Please see CONTRIBUTING.md for Contribution details :100:

bsoyka commented 4 years ago

Going to take this one on too.

CSenshi commented 4 years ago

NOTE: check() takes argument that represents other field name in the same dictionary :

Example:

req = {"old_pass": "secret", "new_pass": "secret"}
rule = {"new_pass": "same:old_pass"}
validate(req, rule)  # True

req = {"old_pass": "old_secret", "new_pass": "new_secret"}
rule = {"new_pass": "same:old_pass"}
validate(req, rule)  # False