-
Notifications
You must be signed in to change notification settings - Fork 78
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
Can't validate MomentJS date object #66
Comments
These is an example on the example page using dates: https://dockwa.github.io/simple-react-validator Here is how it is being used: https://github.com/dockwa/simple-react-validator/blob/master/docs/example.jsx#L87 Also feel free to share you code and I can take a look at it. |
Hi @stuyam, thank you so much for pointing that out, and it's exactly what I was looking for. |
https://github.com/areljannC/simple-react-validator-date-error/blob/master/src/App.js Hi again! The date validation just does not seem to work on my end. Once again, your help is very much appreciated and thank you! |
@areljannC sorry for the late reply. I just now realized what the issue is. We pull the moment object off the window here to use it: https://github.com/dockwa/simple-react-validator/blob/master/src/simple-react-validator.js#L207 In your case this does not work because you are importing moment and it is not on window. Im not actually sure how to do this. As you can see here in the built source we use UMD (Universal Module Definition) to setup the dependency on What I am not sure about is how to set that up to optionally look for moment in stead of looking off the window object like we do now. I'll do some more research on this but would love suggestions if anyone has any ideas or has done something like that before. |
I guess one option would be requiring moment to be passed in to simple react validator on initialize, which would be probably the simplest way instead of doing magic with the different types of setups to check how and if moment is installed. |
@stuyam - can you please tell me some solution to this problem? |
I am also having the same issue even with my date being a moment object. please advise |
"Date validators require using momentjs and moment objects."
The validation gives that error whenever I try to validate a YYYY-MM-DD date.
I am using an input type of "date" and convert the date to a MomentJS date object and it still gives this error.
I looked everywhere in the documentation that covers how to use MomentJS as well as the CodePen you provided but it doesn't cover dates.
It would be great if you can point me to the right direction and thanks for the help!
The text was updated successfully, but these errors were encountered: