-
Notifications
You must be signed in to change notification settings - Fork 0
Date and Time
Majid Ahmaditabar edited this page Dec 10, 2021
·
2 revisions
- The field under validation must be a valid, non-relative date.
- "2020-06-26"
- The field under validation must be a valid, non-relative time.
- am / pm is optional
- "20:13"
- "01:02"
- "02:40am"
- "05:20pm"
- The field under validation must be a valid datetime identifier
- "2020-06-26 12:20"
- The field under validation must be a valid timezone identifier
- "+04:30"
- "-01:30"
data = {
"birthdate": "1990-04-17",
"start_time": "13:30",
"expired": "2020-06-28 12:20",
"my_zone": "+04:30",
}
rules = {
"birthdate": ["required", "date"],
"start_time": ["required", "time"],
"expired": ["required", "datetime"],
"my_zone": ["required", "timezone"],
}
validate = PyValidations.make(data, rules)
- The field under validation must be equal to the given date.
- The field under validation must be a value after a given date.
- The field under validation must be a value after or equal to the given date. For more information, see the after rule.
- The field under validation must be a value preceding the given date.
- The field under validation must be a value preceding or equal to the given date.
data = {
"eq_bd": "1990-04-17",
"after_bd": "1990-04-20",
"after_equal_bd": "1990-04-18",
"before_bd": "1990-04-16",
"before_equal_bd": "1990-04-17",
}
rules = {
"eq_bd": ["required", "date_equals:1990-04-17"],
"after_bd": ["required", "after:1990-04-17"],
"after_equal_bd": ["required", "after_or_equal:1990-04-17"],
"before_bd": ["required", "before:1990-04-17"],
"before_equal_bd": ["required", "before_or_equal:1990-04-17"],
}
validate = PyValidations.make(data, rules)