Skip to content

Core: Added transformation/normalization layer #1609

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

Merged
merged 1 commit into from
Oct 25, 2015

Conversation

Arkni
Copy link
Member

@Arkni Arkni commented Oct 9, 2015

The user can change/transform the value of an element before validating
the element in question. The normalizer value will be then used by
the associated methods instead of the real one.

Ref: #1602

@staabm
Copy link
Member

staabm commented Oct 9, 2015

Will be on vacation for a week. Will review the PR when I am back.

@Arkni
Copy link
Member Author

Arkni commented Oct 9, 2015

Have a good holiday :)

@staabm
Copy link
Member

staabm commented Oct 21, 2015

Please adjust the PR per discussion in #1602

@Arkni
Copy link
Member Author

Arkni commented Oct 21, 2015

Will do soon.

@staabm
Copy link
Member

staabm commented Oct 21, 2015

No need to hurry :-)

@Arkni Arkni force-pushed the transformation-layer branch from 46902d7 to efd641b Compare October 21, 2015 19:12
@Arkni
Copy link
Member Author

Arkni commented Oct 21, 2015

@staabm
Done!

Please let me know if there is anything I missed from our discussion.

// before validating it.
normalizer: function( element ) {
// Trim the value of the input
return $.trim( element.value );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use elementValue instead?

Same in the url normalizer below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my answer above

@staabm staabm changed the title Core: Added transformation layer Core: Added transformation/normalization layer Oct 21, 2015
@Arkni Arkni force-pushed the transformation-layer branch from efd641b to 7c20280 Compare October 21, 2015 20:47
@Arkni
Copy link
Member Author

Arkni commented Oct 21, 2015

@staabm
Updated the PR.

@Arkni Arkni force-pushed the transformation-layer branch from 7c20280 to 5eb030e Compare October 21, 2015 20:50
@staabm
Copy link
Member

staabm commented Oct 21, 2015

Nice. Only things missing

@Arkni
Copy link
Member Author

Arkni commented Oct 21, 2015

a assertion in the test which makes sure this inside the normalizer is the correct DomElement as expected

Done!

a docs PR for the new feature at https://github.com/jzaefferer/validation-content

Will do that, this night I guess (or even tomorrow)

@staabm
Copy link
Member

staabm commented Oct 21, 2015

@Arkni just realised we also need a test which makes sure a exception is thrown when normalizer returns a non string.

@Arkni
Copy link
Member Author

Arkni commented Oct 21, 2015

@Arkni just realised we also need a test which makes sure a exception is thrown when normalizer returns a non string

I will see what I can do.

@Arkni Arkni force-pushed the transformation-layer branch from a311bd4 to a9ae546 Compare October 23, 2015 15:13
@Arkni
Copy link
Member Author

Arkni commented Oct 23, 2015

@Arkni just realised we also need a test which makes sure a exception is thrown when normalizer returns a non string

I will see what I can do.

Done!

@Arkni
Copy link
Member Author

Arkni commented Oct 23, 2015

For the docs, I will create a PR when I have the time, maybe this weekend.

@staabm
Copy link
Member

staabm commented Oct 23, 2015

Awesome, thx.

@Arkni Arkni force-pushed the transformation-layer branch 2 times, most recently from 78226e8 to 43a6a01 Compare October 23, 2015 19:05
@@ -861,7 +877,7 @@ $.extend( $.validator, {
// meta-characters that should be escaped in order to be used with JQuery
// as a literal part of a name/id or any selector.
escapeCssMeta: function( string ) {
return string.replace( /(!|"|#|\$|%|&|'|\(|\)|\*|\+|,|\.|\/|:|;|<|=|>|\?|@|\[|\\|\]|\^|`|\{|\||\}|~)/g, "\\$1");
return string.replace( /([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1" );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have simplified the regex used in escapeCssMeta.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to include it in this PR ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be one \ too much, otherwise lgtm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be one \ too much

nope, one for \ and one for ]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so we should order the escaped \ char somewhere where it doesnt follow directly another escape char. This would ease reading

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense. maybe like this:

/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

The user can change the value of an element before validating
the element in question. The new value will be then used by
the associated methods instead of the `real one`.

Closes jquery-validation#1602
@Arkni
Copy link
Member Author

Arkni commented Oct 24, 2015

Arkni added a commit to Arkni/validation-content that referenced this pull request Oct 25, 2015
staabm added a commit that referenced this pull request Oct 25, 2015
Core: Added transformation/normalization layer
@staabm staabm merged commit a6151f9 into jquery-validation:master Oct 25, 2015
@staabm
Copy link
Member

staabm commented Oct 25, 2015

Awesome sauce 🌟

@Arkni Arkni deleted the transformation-layer branch October 25, 2015 20:01
@Arkni
Copy link
Member Author

Arkni commented Oct 25, 2015

😃

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

Successfully merging this pull request may close these issues.

2 participants