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: DateFormat:format #77

Open CSenshi opened 4 years ago

CSenshi commented 4 years ago

Rule Name: DateFormat

Rule Arguments:

  1. format - String that represents python datetime format

Rule Description: The field under validation must match the given format

Rule Usage Example:

reqs = {'data' : '2018-06-29 08:15:27'}
rule = {'data' : 'date_format:%Y-%m-%d %H:%M:%S'}
validate(reqs, rule) # True

reqs = {'data' : '2018-06-29 08:15:27'}
rule = {'data' : 'date_format:%Y-%m-%d'}
validate(reqs, rule) # False, because 08:15:27 is unconverted data

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