-
Notifications
You must be signed in to change notification settings - Fork 174
Using model value #271
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
Using model value #271
Conversation
src/rule.js
Outdated
| email: /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/, | ||
| number: /^\d+$/, | ||
| minlength: function(value, scope, element, attrs, param) { | ||
| value += ''; |
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.
why do we need this stringify?
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.
The reason is as follows: if we use $modelValue whose value data type is Number, then value.length results in undefined;
The question is, if the validator "maxlength" or "minlength" should be used with the Number data type; instead, maybe something like "maxVal" and "minVal" could be created on the app side.
In that case, It would be probably desired to remove usage of the maxlength from tests.
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.
yes, this is valid.
But I would like to remove this commit out of this pr scope (using model value)
then we can have another pr/commit for separate maxlength and maxvalue but it doesn't really matter, it's just a rule and everyone can customise it. 🙂
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.
Ok, perfect. So Ill remove the string conversion, update the related tests and squash the commits to single one. Regarding the validation expression, your correct - it doesn't really matter now.
The last thing: "can you remove those unwanted indent/format commit?" could you please specify
more in detail which lines should be changed? (If not already discussed above) Thanks :)
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.
Ok, perfect. So Ill remove the string conversion, update the related tests and squash the commits to single one. Regarding the validation expression, your correct - it doesn't really matter now.
Perfect 🍻
more in detail which lines should be changed? (If not already discussed above) Thanks :)
Sure.
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.
So Ill remove the string conversion, update the related tests and squash the commits to single one.
Done
more in detail which lines should be changed? (If not already discussed above) Thanks :)
Sure.
If there's anything else left to be done, let me know please :) Thanks.
|
yes, this is a real need case. can you remove those unwanted indent/format commit? |
75c9099 to
d3116f4
Compare
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.
Nope, it is not done yet. if you didn't update anything on demo.js, please kindly revert the change of demo.js, otherwise I can't merge this commit.
demo/demo.js
Outdated
| // ------------------- | ||
| .config(['$validationProvider', function($validationProvider) { | ||
| var defaultMsg; | ||
| var expression; |
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.
unwanted indentation commit.
demo/demo.js
Outdated
| error: 'This is a error url given by user', | ||
| success: 'It\'s Url' | ||
| } | ||
| }; |
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.
same here.
demo/demo.js
Outdated
| error: 'This no ip', | ||
| success: 'this ip' | ||
| error: 'This isn\'t ip address', | ||
| success: 'It\'s ip' |
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.
try not to update the text, because it is out of scope.
| alert('Error ' + message); | ||
| }; | ||
| }]); | ||
| }).call(this); |
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.
Indeed, we don't update anything on this file demo.js, unless you add an example for useViewValue in demo page.
d3116f4 to
1082a12
Compare
|
Okay, now I see where was the unwanted indentation. It came by mistake, sorry. It should be fixed now. |
hueitan
left a comment
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.
Perfect now!
|
There are still some conflicts over the file, do you mind pull the latest from master, and run the grunt build again? |
1082a12 to
c538ea9
Compare
|
Seems like it should be fine now. What do you think? :) |
|
yep, done! 🍻 |
|
There is one more thing we can improve, try to add the explanation in Q&A section. with the explanation you given above
|
|
It seems like I had to create a new PR for this one, so there's another opened... |
Allows user to specify, weather to use $viewValue or $modelValue for evaluation when form is submitted.
By default uses $viewValue; by adding use-view-value="false" forces to use $modelValue;
This need raises from a need of localized number inputs, which have to be stored in a $viewValue as a string (e.g. "2 000,0"), however in a $modelValue they are stored as a properly formatted number (2000). This can be done by using a custom directive with properly specified $formatters and $parsers.