repocrypts / Validator

Client-side javascript validator library ports from Laravel 5.2
MIT License
46 stars 22 forks source link

Enhancement in result #13

Closed prashant-saxena closed 4 years ago

prashant-saxena commented 6 years ago

Hi,

First of all I really appreciate your work on this script. Everything is pretty straight forward and easy, how ever I'm looking for an enhancement in the final results provided by getErrors function. I'm not much into java script but if you can guide me It would be great.

By default the return object id in this form: email: Array [ "You forgot the email field", "email is not valid" ] ​password: Array [ "You forgot the password field", "The password must be between 10 and 20 characters." ] Here we have no way to tell which message is related to which error.

For example: email: Array [ requierd:"You forgot the email field", email:"email is not valid" ] ​password: Array [ required:"You forgot the password field", between:"The password must be between 10 and 20 characters." ]

Instead of plain array if we can have an object of messages like above then it would be easier to take appropriate action based on rule.

Do we have to change the every other function or is there a single place where this could be implemented?

Many Thanks Prashant

jfstn commented 4 years ago

I'll think about this for the new version. Thanks.