vuetify required field allow 0

Solutions on MaxInterview for vuetify required field allow 0 by the best coders in the world

showing results for - "vuetify required field allow 0"
Nathan
22 Sep 2016
1// I want the fields of my form to be required (using Vuetify built-in validation).
2// Some of them are numbers and Vuetify doesn't like when I input 0 (because 0 == false).
3// The solution is to evaluate a string inside of the 'required' method. 
4
5// Instead of writing this : 
6
7rules: {
8  required: v => !!v || 'Field is required',
9}
10// (If v is NOT not false (!!v), return true, else return 'Field is required')
11
12// Just write this : 
13
14rules: {
15  required: v => !!`${v}` || 'Field is required'
16}