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: Hex #90

Closed CSenshi closed 4 years ago

CSenshi commented 4 years ago

Rule Name: Hex

Rule Description: The field under validation must be a hexadecimal number

Rule Usage Example:

reqs = {"data" : "A1B2c3"}
rule = {"data" : "hex"}
validate(reqs, rule) # True

reqs = {"data" : "0xA1b2C3"}
rule = {"data" : "hex"}
validate(reqs, rule) # True

reqs = {"data" : "abcdefgh"}
rule = {"data" : "hex"}
validate(reqs, rule) # False, It fails because 'g','h' are not in hexadecimal

Before contributing please review RULES.md (check for duplication), also check CONTRIBUTING.md for more details :100: