-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Core: Adding a way to pass method name to remote #1657
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
Conversation
1d89469
to
8d96f00
Compare
Hi, just wanted to get an update on this pull-request? :) |
@wojwal thx for the PR. It somehow slipped thru :-) I like it. Could you rebase it and add unit tests? |
I'm not against this approach, but can't we achieve the same result if we use: Please correct me if I misunderstood something. |
@staabm - I just rebased the code - so that part is ready. As for test units - I reviewed "test" folder, but it will take me some time to understand, how to do it properly - I'll do it when I got some spare time. @Arkani - Not sure I guess your solution will work, but there is much more you can do with solution I proposed. For example:
I guess it's always better to have multiple possibilities ;) |
So your idea is using the Feel free to tag me whenever you need any help regarding the unit test :)
|
if ( this.optional( element ) ) { | ||
return "dependency-mismatch"; | ||
} | ||
|
||
var previous = this.previousValue( element ), | ||
method = typeof method === "string" ? method : "remote"; |
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 this can be changed to:
method = method || "remote";
22965c5
to
6345f73
Compare
Hi guys ;) I've added tests for this, which includes:
@Arkni - as for your suggestion - I'm fine with either case. Your suggestion is just little less strict (not checking if value is string) - but thats not a big deal... |
I know, but what will happen if a user passed an empty String (in a test for example) ? method = typeof method === "string" && method || "remote"; Otherwise, LGTM :) |
I just commited that change ;) |
HI guys, pls merge my changes... Anything missing? Thanks |
@wojwal please rebase the branch against master. After I merge some other PRs today it is no longer mergeable. Will merge after your rebase ASAP. thanks. |
This allows reusing remote as custom method via addMethod
@staab rebased ;) |
@wojwal thx |
Just note this introduce a BC Break for those developers with custom validation functions. This should be highlighted in the CHANGELOG |
How so ? |
If the additional argument is not provided then When |
So if previousValue |
@Maks3w please open a new issue |
No, that's not true. If the argument is not provided, then |
|
Sorry, but I still didn't get it. Maybe you can open an issue and provide a simplified example (in jsfiddle or something else). |
No need of jsfiddle
|
Ah, I see. Thanks for the explanation. This should be fixed as soon as possible, minor releases should never introduce breaking changes. |
@Arkni I would like to release 15.1 next week, could you provide a fix for this until then? |
One note defaultmessage has changed his behavior and the second argument must be an object. I'll put the note on the original PR if I found, |
Sure! |
As of now the signature of `validator.defaultMessage( element, string )` is deprecated. Use `validator.defaultMessage( element, object )` instead where objet is defined as ``` object = { method: "method name", parameters: "the given method parameters" } ```
This allows reusing remote as custom method via addMethod. Without this fix it will show standard "remote" message - instead of custom message from addMethod.
Sample usage:
And in HTML I'm just using data-rule-workemail='true' attribute for input