gtournie / redux-form-validators

redux-form-validators
153 stars 22 forks source link

allow white space #61

Closed AndyOGo closed 5 years ago

AndyOGo commented 5 years ago

Similar to allowBlank I would like to allow white space around the user's input. Upon onBlur it will be normalised and trimmed.

I use this Field replacement for on-blur-normalization: https://github.com/jcoreio/redux-form-normalize-on-blur

Use cases are:

AndyOGo commented 5 years ago

hmh maybe a generic value normalization hook would be a good idea 🤔

gtournie commented 5 years ago

I don't think this is a very common use case. Plus, it would be a pain to implement with some of the validators.

Maybe there is another way to do that. This is what I'm doing in one of my project:

AndyOGo commented 5 years ago

Thanks for your quick answer @gtournie

Yeah, we tried normalize already. We just didn't like that unprofessional users could get the idea that their input isn't recognized if they press space either at the beginning or end.

So we wanted a normalization upon onBlur, but this leads to false-negatives of our validations. So I just wrapped all validations for <Field /> within a dedicated validation funcion, which first normalizes the value and then delegates to the validator.

So it's very simple to archive what we want from the outside, from my point of view this ticket can be closed.