poppinss / indicative

Indicative is a simple yet powerful data validator for Node.js and browsers. It makes it so simple to write async validations on nested set of data.
https://indicative.adonisjs.com/
MIT License
417 stars 52 forks source link

Feature/lowerCase & upperCase sanitizations #211

Closed AndrewJo closed 5 years ago

AndrewJo commented 5 years ago

Proposed changes

This PR adds support for adding lowerCase and upperCase sanitization rules. It can take in 1 optional argument for locale awareness. If argument is omitted, it will attempt to use the default system locale (see MDN documentation).

Types of changes

What types of changes does your code introduce?

Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

AndrewJo commented 5 years ago

@thetutlage I reckon you've been pretty busy but if you can, please review this and #203 (which have been open since last year).

thetutlage commented 5 years ago

Thanks 😄

zeeshanyshaikh commented 5 years ago

How to use this? Am trying this in Adonis framework.

get sanitizationRules () { return { email: 'normalize_email', username: 'lowerCase' } }

But its not working.. :( Is this change available in @adonisjs/validator v5.0.6 ?

AndrewJo commented 5 years ago

@zeeshanyshaikh unfortunately, no, this change isn't available in @adonisjs/validator v5.0.6. The changes in this PR only made it in to v6.0.0 which was released just couple of weeks ago. Unfortunately, @adonisjs/validator v5.0.6 was released almost 6 months ago which was way before any of these improvements were merged in.

I believe @thetutlage has been busy overhauling AdonisJs to TypeScript (not to mention his day-to-day job) so you probably won't see the changes until he releases AdonisJs (or AdonisTs?) v5.

If you really need the features, my suggestion is to fork @adonisjs/validator and npm/yarn update to use indicative v6. Read the CHANGELOG.md for indicative v6 carefully for backwards breaking changes that you'll have to fix. Once you fix them, contribute and make the framework better for the community by submitting a pull request.