-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Adding additional date validation options. #168
Adding additional date validation options. #168
Conversation
This is fantastic! The one thing I dont like is the
|
I have no preference, I was just copying moment js method name format. I updated the code to OrOn format. |
Okay you might hate be but can you change it to |
I can change it, one thing I did like about beforeOrOn / afterOrOn, is that if your validators were previously before / after, it was less work / error prone to change to beforeOrOn or afterOrOn by just appending onto the end. If you still want it changed after that input I'll do it. Let me know. |
True, but doing a simple find/replace from |
Its changed |
👍 Thanks for dealing with my antics! Ill merge once the build passes. |
No problem. Glad to help out |
Im sorry, just for clarification, is the default precision in moment |
In moment js the default is milliseconds as seen here We could add that option, but it seemed far more granular than a validation would ever need. |
I don't think that we should actually default the precision. I'm assuming On Saturday, April 16, 2016, Aaron Hansen notifications@github.com wrote:
Thanks, |
I removed the default precision. I didn't list milliseconds as an option, since thats what it internally defaults to anyway if we don't pass it in. |
@@ -53,9 +59,11 @@ export default Base.extend({ | |||
}, | |||
|
|||
validate(value, options) { | |||
options = assign({}, options); |
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.
This line isn't needed here because the options object is already a new pojo created from processOptions
method. You can also remove the const assign
declaration from the top.
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.
Yep your right, I thought it shouldn't need it. The tests are mutating the options because processOptions isn't called. I need to clone the object in the tests. I'll get that fixed.
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.
Made the changes, let me know if you want anything else done.
👍 Thanks for taking the time to make all those changes @aaronbhansen! |
No problem, glad to help out. Next pull request I'll know what you're looking for more 😄 |
I needed some additional date validation checks. Rather than write a custom validator, I figured I would create a pull request adding the functionality.
This adds two new date validation options:
beforeOrSame
afterOrSame
Also added a precision quantifier so that if you are passing full dates in from ember data or another source you could quantify what to compare on. For example, you could limit the precision to 'day' to ignore any time differences.