Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

WIP Validator\Date with format 'd' return true with data 6 #33

Closed
wants to merge 3 commits into from
Closed

WIP Validator\Date with format 'd' return true with data 6 #33

wants to merge 3 commits into from

Conversation

gianarb
Copy link
Contributor

@gianarb gianarb commented Aug 6, 2015

I wrote this test because 'd' is day of week with 2 digits but for Validator\Date 6 is valid

@svycka
Copy link
Contributor

svycka commented Aug 19, 2015

would be nice if zendframework/zendframework#6407 would be fixed too.

$validator = new Date(['format' => 'Y-m-d']);
$this->assertFalse($validator->isValid(123)); // fails

public function testFormatDayTwoDigits()
{
$validator = new Date(['format' => 'd']);
$this->assertFalse($validator->isValid("6"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use validator failure message as second argument of assertFalse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Maks3w the problem is the result of validation not the failure message

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gianarb I know but is better if PHPUnit fail with a better description message rather true is not equal to false :)

@Maks3w
Copy link
Member

Maks3w commented Aug 20, 2015

@gianarb Test case should be part of datesDataProvider

@weierophinney
Copy link
Member

Pinging @gianarb — do you have time to incorporate the feedback?

@gianarb
Copy link
Contributor Author

gianarb commented Feb 17, 2016

I do it now

Gianluca Arbezzano added 3 commits February 17, 2016 16:36
format 'd' Day of the month, 2 digits with leading zeros but now
Zend\Validator return inconsitent check
@weierophinney
Copy link
Member

@gianarb Thanks.

Now the question is: is this a problem with the validator, or with DateTime...

@weierophinney
Copy link
Member

I'm still stumped by this, but now for a different reason: Are you asserting that given a format d, meaning a day, and a value of '6', this is invalid because it is not zero-padded? I'm not entirely sure I agree that this would be problematic behavior; I could see a case for any single digit (minus zero itself) being valid.

Can you clarify, please?

@gianarb
Copy link
Contributor Author

gianarb commented Aug 17, 2017

I can't because I don't remember anymore sorry.

@michalbundyra michalbundyra mentioned this pull request Oct 12, 2019
8 tasks
@gianarb gianarb closed this Nov 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants