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

Comments

Projects
None yet
3 participants
@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 referenced this issue Dec 21, 2016

Closed

Fixes #188 #189

@ansman

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Mar 21, 2017

Owner

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

Owner

ansman commented Mar 21, 2017

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

@jtuds

This comment has been minimized.

Show comment
Hide comment
@jtuds

jtuds 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.

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

This comment has been minimized.

Show comment
Hide comment
@roly445

roly445 Sep 25, 2017

I am having the same issue here

roly445 commented Sep 25, 2017

I am having the same issue here

@ansman

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Oct 17, 2017

Owner

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

Owner

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

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Oct 17, 2017

Owner

A fix has been released in 0.12.0

Owner

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