Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

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

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

Comments

@jtuds
Copy link

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 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 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 commented Sep 25, 2017

I am having the same issue here

@ansman
Copy link
Owner

ansman commented Oct 17, 2017

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

@ansman ansman closed this as completed 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 commented Oct 17, 2017

A fix has been released in 0.12.0

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

No branches or pull requests

3 participants