horprogs / Just-validate

Modern, simple, lightweight (~5kb gzip) form validation library written in Typescript, with no dependencies (no JQuery!). Support a wide range of predefined rules, async, files, dates validation, custom error messages and styles, localization. Support writing custom rules and plugins.

Home Page:https://just-validate.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

minLength and maxLength are validated even when field is not required

rophini92 opened this issue · comments

Hi,

Great validation library, but I have an issue...

Describe the bug
When I set minLength and/or maxLength on a field that is not required, I expect no validations errors when te field is empty. But the validation kicks in.

Expected behavior
As the field is not 'required', the minLength and maxLength validation should be valid. The min and/or maxlength should only be validated when the user has filled in the field

Thanks!

Hi! Could you please make sure you are using the latest version? And could you please share your code, as you can check it here it doesn't validate field if it's not required

https://just-validate.dev/playground

Ah, my fault, sorry, I was to quick. I wrote my own kind of handler to use html-attributes to create and validation rules using your library. I had to parse my minlength attribute to an int!