Answers for "vuetify required field allow 0"

0

vuetify required field allow 0

// I want the fields of my form to be required (using Vuetify built-in validation).
// Some of them are numbers and Vuetify doesn't like when I input 0 (because 0 == false).
// The solution is to evaluate a string inside of the 'required' method. 

// Instead of writing this : 

rules: {
  required: v => !!v || 'Field is required',
}
// (If v is NOT not false (!!v), return true, else return 'Field is required')

// Just write this : 

rules: {
  required: v => !!`${v}` || 'Field is required'
}
Posted by: Guest on May-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language