Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form validation: How to manually set errors #480

Closed
ahoiroman opened this issue Aug 1, 2023 · 1 comment · Fixed by #487
Closed

Form validation: How to manually set errors #480

ahoiroman opened this issue Aug 1, 2023 · 1 comment · Fixed by #487
Labels
question Further information is requested

Comments

@ahoiroman
Copy link

As I am working against an API, I was using vee-validate to validate on frontend and Laravel to validate on backend.

In the past I used something like this to display an error on a field, which enabled me to set a field to have an error:

<UFormGroup name="password" :error="!!errors.password">
              <UInput v-bind="passwordBind" name="password" type="password"/>
</UFormGroup>

<script setup lang="ts">

const {handleSubmit, errors, defineComponentBinds, setErrors} = useForm<SignUpForm>({...})

function onFailedApiCall(response){
  setErrors(response)
}
</script>

Now I am doing this:

          <UForm  ref="form"
                  :schema="schema"
                  :state="state"
                  @submit.prevent="onSubmit"
                  class="space-y-6">
            <UFormGroup name="password" required>
              <UInput v-model="state.password" name="password" type="password"/>
            </UFormGroup>
          </UForm>

This does not allow me to set errors manually. Or did I just not see it yet?

@ahoiroman ahoiroman added the question Further information is requested label Aug 1, 2023
@ddahan
Copy link

ddahan commented Aug 2, 2023

May be related: #474

I agree with this need (probably the single missing feature that prevents me to use it in production).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants