mikeerickson / validatorjs

A data validation library in JavaScript for the browser and Node.js, inspired by Laravel's Validator.
https://www.npmjs.com/package/validatorjs
MIT License
1.77k stars 280 forks source link

same:attribute rule not respecting label aliases #138

Closed dcworldwide closed 6 years ago

dcworldwide commented 7 years ago

Issue with same:attribute rule not respecting label aliases.

Code

        let validator = new Validator(
            {
                aEmail: this.aEmail,
                aEmail2: this.aEmail2,
            }, {
                aEmail: 'required|email',
                aEmail2: 'same:aEmail',
            }
        )

        validator.setAttributeNames({
            aEmail: 'email',
            aEmail2: 'repeated email',
        })

Error:

screen shot 2016-10-30 at 15 02 20

Label should not say aEmail.

zulis commented 6 years ago

Have problems with 'same' rule as well :/

robclancy commented 6 years ago

30 October 2016 and this is still a thing huh.

iamdtang commented 6 years ago

@robclancy would love some help if you are interested in contributing.

robclancy commented 6 years ago

@skaterdav85 it legit took me the amount of time since I posted that to find how to do this. And then I see this PR https://github.com/skaterdav85/validatorjs/pull/225 which does it for the other fields and you literally just need to do a copy paste and change some text to same.

robclancy commented 6 years ago

If you can merge that PR I can make a new PR to do the copy pasting that is needed.

iamdtang commented 6 years ago

I just replied on that PR asking the author to add some tests since I'm not clear what those changes were for. It has been awhile since I've worked on this library and the last thing I want to do is start breaking things.

iamdtang commented 6 years ago

@robclancy released on 3.13.6