Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date type max attribute collision with max validaton #814

Closed
khelll opened this issue Jan 2, 2015 · 13 comments
Closed

Date type max attribute collision with max validaton #814

khelll opened this issue Jan 2, 2015 · 13 comments

Comments

@khelll
Copy link

khelll commented Jan 2, 2015

I want to have the attribute 'max' on date type input, and I just want to make sure parsley is validating the presence of value. However, due to the fact that parsely is using the keyword max to validate integer values, it's suggesting that the date type file is invalid although such type of validation is not required.

@khelll
Copy link
Author

khelll commented Jan 3, 2015

Moreover, if you have numeric value in data-parsley-value, you get 'You must validate an object or a string'

@MichaelAllenMiller
Copy link
Contributor

@guillaumepotier This seems like a pretty big oversight. Do you know if anyone is working on it already? If not, is there any specific way you'd like to see this implemented? Or is the preferred approach to use custom validators for date ranges?

@marcandre
Copy link
Collaborator

Nobody is working on it, and it should definitely be fixed! The max, min and range validators should be changed.
PR welcome if you feel like it:

  • ideally work off the branch es6 that I hope to merge asap.
  • first idea that comes to mind would be to add a validateDate to the API, and add such a method to the min, max and range validators. Their requirementType will have to be string though and parsed within validateDate and validateNumber. Alternative would be to instead convert them to use a generic validateString?

@Flaburgan
Copy link

+1 on this. It looks like there is no date validator in parsley, so actually, I guess input type="date" should be completely ignored to avoid collision with native validation of min and max attributes.

@unilynx
Copy link

unilynx commented Aug 7, 2016

I'm running into the same problem, and am working on a fix here: https://github.com/WebHare/Parsley.js/tree/fix-814

I'm not sure how to deal with the error reporting.

It will now return 'This value seems to be invalid.'. Ideally I would use the standard min,max and range' errors, but then I'd run into locale issues on properly formatting the date in the response.

I'll submit it as a PR anyway, as input type=date with min/max/range is currently broken anyway.

@cedricnicolas
Copy link

Still not solved ? I have the issue while putting a min on input type="date"...
Uncaught Requirement is not a number: "2016-09-08"

@marcandre
Copy link
Collaborator

I'm afraid not. There's a PR in the works, although I suspect there is a better approach to improve the range/min/max validators.

@Stadly
Copy link

Stadly commented Sep 27, 2016

Any news on this?

@Thumbleweed
Copy link
Contributor

i've created a pull request (#1158) for this one.
what it does is ignoring the range/min/max attribute validator, when used on a date field.

@Flaburgan
Copy link

@Thumbleweed I had to do that yes, and then create a custom validator for min and another for max. Would be better to see parsley supporting that natively than hiding the problem though...

@Thumbleweed
Copy link
Contributor

That is true @Flaburgan . my pull request just prevents parsley from breaking when using a min/max attribute on a date field.

@marcandre
Copy link
Collaborator

I took a stab at date support. Even allows easy custom validators for date that implement validateDate, and/or requirements of type 'date'

If interested, have a look at #1168

@marcandre
Copy link
Collaborator

Fixed in 2.7.0.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants