tgriesser / checkit

simple, flexible validations for node and the browser
MIT License
223 stars 53 forks source link

Transform the property after validate #80

Closed Chubby-Chocobo closed 6 years ago

Chubby-Chocobo commented 7 years ago

Hi, I'm using Checkit in my web project to validation the request's parameters like this:

var [err, params] = new Checkit({
      id: ['required', 'naturalNonZero']
    }).validateSync(req.params);

But the type of params.id is still string. I want it to be integer actually. or another case:

var [err, params] = new Checkit({
      tags: ['parseableNumericArray'],
    }).validateSync(req.params);

with parseableNumericArray is a customized validation. I think if params.tags can be array of number instead of string after validation, it would be great.

Can we do that with Checkit currently? Or can I make a pull request? Is this project being maintained? I see it's a while since the last update... Thanks for your attention.

joepie91 commented 7 years ago

I would argue that it's only checkits job to validate your values, not to modify or use them in any way. In the interest of keeping the module focused, it's probably better if you convert the value yourself after the validation has passed.

Chubby-Chocobo commented 6 years ago

It's ok then.