-
Notifications
You must be signed in to change notification settings - Fork 136
Strict mode for Date validator #275
Strict mode for Date validator #275
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe in v3, we could leave the only strict mode?
src/Date.php
Outdated
* @param bool $strict | ||
* @return $this | ||
*/ | ||
public function setStrict($strict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe drop php5.6 and add boolean type-hint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in v2.
['6', 'd', true, false], | ||
['06', 'd', true, true], | ||
[123, null, true, false], | ||
[1340677235, null, true, false], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also add Unix timestamp with a format here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that input argument must be string even for U
format. Output of DateTime::format
is always a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for the new strict mode is needed. The following points should be included:
- Why is the strict mode required?
- Which mode should be preferred?
- And like always: code examples
Input must be always in the defined format and must be the same as output of format method of DateTime. Strict mode is set to `false` by default to keep BC. Resolve #33 Fix zendframework/zendframework#6407
Updates new methods of Date validator and its tests to use typehints. Updates license docblock year range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since #264, the develop branch now targets PHP 7.1. As such, I've pushed changes to add typehints to the newly introduced methods, which will prevent BC breaks in the future, and simplifies their implementation.
I've also added documentation on the new strict mode.
Input must be always in the defined format and must be the same as output
of format method of DateTime.
Strict mode is set to
false
by default to keep BC.Currently to the validator we can provide
integer
,double
,array
,string
orDateTimeInterface
value. In my opinion as validator has set format we should check if the input value has exactly the same format as set.In strict mode we are comparing if:
Resolve #33
Fix zendframework/zendframework#6407
develop
branch, and submit against that branch.CHANGELOG.md
entry for the new feature.I would see strict mode by default enabled in v3, or ONLY strict mode in v3.
Thoughts?
/cc @svycka @gianarb