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

feat(validation): add to $errors if the validator has $message #521

Merged
merged 3 commits into from
Aug 15, 2020

Conversation

pikax
Copy link
Owner

@pikax pikax commented Aug 15, 2020

fix #493

If a validator has a $message and the validations fails it will be added to the $errors

    const $message = "Invalid value";
    const v = useValidation({
      input: {
        $value: "",
        required: {
          $validator(x: string) {
            return false;
          },
          $message
        }
      },
      otherInput: {
        $value: "",
        required(x: string) {
          return false;
        }
      }
    });

    expect(v.input.$errors).toMatchObject([$message]);
    expect(v.otherInput.$errors).toMatchObject([]);

@pikax pikax merged commit 7e79920 into master Aug 15, 2020
@pikax pikax deleted the feat/validation_errors branch August 15, 2020 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: useValidation does not populate $errors
1 participant