vuetify icon indicating copy to clipboard operation
vuetify copied to clipboard

fix(validation): validate initial input value

Open nekosaur opened this issue 2 years ago • 3 comments

Description

closes #15568

this is a change to default behaviour, but I think the old behaviour could be classified as a bug.

Markup:

<template>
  <v-form v-model="valid">
    <v-text-field autofocus label="name" v-model="name" required :rules="nameRules"></v-text-field>
    <v-text-field label="type" v-model="type" required :rules="typeRules"></v-text-field>
  </v-form>
  Valid: {{ valid === null ? 'null' : valid }}
  <v-btn :disabled="!valid">Sa</v-btn>
</template>

<script>

  export default {
    data () {
      return {
        valid: false,
        name: '',
        type: 'asdasdasdasd',
        nameRules: [(v) => (!!v && v.length > 5) || "EDITOR.stories.storyNameRequired"],
        typeRules: [(v) => !!v || "EDITOR.stories.typeIsRequired"],
      }
    },
  }
</script>

nekosaur avatar Apr 09 '23 11:04 nekosaur

TODO: this has the same issue as optional PR in that empty value is different for different components so just checking if(model.value) is probably not enough

nekosaur avatar Apr 10 '23 15:04 nekosaur

TODO: this has the same issue as optional PR in that empty value is different for different components so just checking if(model.value) is probably not enough

What about a clearFunction property that each component would define?

johnleider avatar Apr 19 '23 15:04 johnleider

This should be more similar to v2.

  • Inputs should always be validated initially no matter what the value is
  • There should be some way to run validation "silently" without displaying errors to the user
  • There should be some way to disable the initial validation, for example if async rules are used

KaelWD avatar May 03 '23 14:05 KaelWD