vue-formulate
vue-formulate copied to clipboard
Validation "between" is not inclusive
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:
- open codepen link below
- enter an 8 character password
- 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
Device information:
- Device: asus zenbook
- OS: ubuntu 18
- Browser : chrome
- Version: 83
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.
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)
Small update on this — the next major version (where we can introduce breaking changes) will change this rule to be inclusive.
@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.
Version 3 is FormKit and it uses inclusive validation rules