vue-formulate icon indicating copy to clipboard operation
vue-formulate copied to clipboard

Validation "between" is not inclusive

Open clairefro opened this issue 4 years ago • 6 comments

Describe the bug Using validation "between" is not inlcusive and therefore gives misleading validation message.

<FormulateInput
   type="password"
   name="password"
   label="New password"
   validation="required|between:8,64,length"
 />

Entering an 8 character password returns the validation "New password must be between 8 and 64 characters long.", whereas one would expect the range to be inclusive.

My work-around for this is to use a custom validation message, while behind the scenes setting the range to between,7,65,length.

To Reproduce Steps to reproduce the behavior:

  1. open codepen link below
  2. enter an 8 character password
  3. blur focus on the input for validation message to appear

CodePen:

https://codepen.io/clairefro/pen/bGEzLqJ

Expected behavior Expect validation "between" range to be inclusive

Screenshots image

Device information:

  • Device: asus zenbook
  • OS: ubuntu 18
  • Browser : chrome
  • Version: 83

clairefro avatar Jul 22 '20 14:07 clairefro

I agree...this isn't the the best UX. and if we fix the message then it will be a confusing DX. maybe we should switch all Vue Formulate rules to be inclusive? We could do this with a flag to prevent breaking changes:

Vue.use(VueFormualte, {
  inclusiveRules: true
})

I think between, min, and max suffer from similar issues. Open to suggestions on this since it's really a UX thing.

justin-schroeder avatar Jul 27 '20 16:07 justin-schroeder

a flag like you suggest would be great.

Currently it is a confusing UX and DX as the developer needs to add a custom validation message to clarify the unclear default messaging to the user. (Personally, I always read 'between 8 and 64' to be inclusive, especially since 8 is a common min value for passwords)

clairefro avatar Jul 27 '20 18:07 clairefro

Small update on this — the next major version (where we can introduce breaking changes) will change this rule to be inclusive.

justin-schroeder avatar Aug 02 '21 20:08 justin-schroeder

@justin-schroeder Any update on version 3?

Trying to adopt Formulate in our project but having to write custom logic and messages for every length-dependant field beause we use includsive values is very cumbersome. I can also override the rule on a global level but then my whole argument of "this is simpler than what we have" starts to get thin.

ivoiv avatar Mar 28 '22 18:03 ivoiv

Version 3 is FormKit and it uses inclusive validation rules

justin-schroeder avatar Mar 28 '22 18:03 justin-schroeder

Version 3 is FormKit and it uses inclusive validation rules

Gotcha, thanks!

ivoiv avatar Mar 28 '22 18:03 ivoiv