Skip to content
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

Escaped dots in constraints don't validate against input names with dots #188

Closed
jtuds opened this issue Dec 21, 2016 · 5 comments
Closed

Escaped dots in constraints don't validate against input names with dots #188

jtuds opened this issue Dec 21, 2016 · 5 comments
Labels
Milestone

Comments

@jtuds
Copy link

@jtuds jtuds commented Dec 21, 2016

When an input name has a dot, e.g. name="input.name" and a constraint is added for that input, e.g.

"input\\.name": {
    presence: true
}

the constraint will not validate against the name. This is because the escaping (of the dot) only happens when getting the input value and not when applying the errors to the inputs.

@jtuds jtuds mentioned this issue Dec 21, 2016
@ansman
Copy link
Owner

@ansman ansman commented Mar 21, 2017

I'm a bit unclear on the problem, what are you expecting and what are you seeing?

@jtuds
Copy link
Author

@jtuds jtuds commented Apr 12, 2017

If I have an input field like this <input type="text" name="foo.bar" /> and in the constraints object I have

"foo.bar": {
    presence: true
}

Or

"foo\\.bar": {
    presence: true
}

I would expect the input field to be validated and to be checked for a presence of true, and then if presence is false, for an error to be added to the input. In the second constraints example I have escaped the period that appears in the input name (foo[period]bar). The input is validated, however the error is not correctly added to the input. I believe this is because escaping characters, i.e. "\" are not removed from the input name before being ran through the validator. So in this instance, when applying the error, the validator is looking for for an input with the name foo\\.bar which doesn't exist. It should look for foo.bar without the slashes.

@roly445
Copy link

@roly445 roly445 commented Sep 25, 2017

I am having the same issue here

@ansman
Copy link
Owner

@ansman ansman commented Oct 17, 2017

Isn't the problem just that collectFormValues doesn't replace . with \\.?

@ansman ansman closed this in ff04862 Oct 17, 2017
@ansman ansman added this to the 0.12.0 milestone Oct 17, 2017
@ansman ansman added the bug label Oct 17, 2017
@ansman
Copy link
Owner

@ansman ansman commented Oct 17, 2017

A fix has been released in 0.12.0

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

Successfully merging a pull request may close this issue.

None yet
3 participants