iamjpcbau
iamjpcbau

Reputation: 404

React.js: How to use isLength in validator library?

I'm using validator library for my password validation

I'm trying to use each validator for custom use

However, I'm having problem when using isLength validator to see if max length is invalid

validator.isLength(e.target.value [, options])

e.target.value is my string from the Textfield

According to the documentation, options is an object which defaults to {min:0, max: undefined}. Note: this function takes into account surrogate pairs.

How do I declare the maximum possible length with that syntax?

validator.isLength(e.target.value [0, 5]) is not working

Should I create an object first? With {"min":"0","max":"5"}

Upvotes: 1

Views: 1530

Answers (1)

Vivek Doshi
Vivek Doshi

Reputation: 58593

Yes, as per the doc , it should look like this

validator.isLength(e.target.value , {min:0, max: 5})

Upvotes: 4

Related Questions