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

Validator with the "individual usage" configuration has no validation rules #163

Closed
loicdekester opened this issue Apr 18, 2023 · 2 comments

Comments

@loicdekester
Copy link

Development Relevant Information:

  • BalmUI version: 10.18.1
  • Browser: Chrome Version 111.0.5563.147 (Official Build) (64-bit)
  • Operating System: Widows 10

Description:

I am trying to use the validator with the "individual usage" configuration but I get console warnings saying the field doesn't have a validation rule. ==> The field 'length' is missing a validation rule: 'required'
Even though required is a default rule.
I even tried a custom rule and didn't have more luck.

Steps To Reproduce:

Here is a link to see the error: https://stackblitz.com/edit/vue-exxmy9?file=src/main.js
The form has a input event that triggers the validation.

@elf-mouse
Copy link
Member

elf-mouse commented Apr 19, 2023

Hi @loicdekester , you need to modify your code like this:

  • validatorRules.js

    export default {
      required: {
        validate(value) {
          return !value;
        },
        message: '%s is empty',
      },
      // ...
    };
  • HelloWorld.vue

    import { useValidator } from 'balm-ui/plugins/validator'; // Because of individual usage
    
    // ...
    
    function validate() {
      const { valid, validMsg } = validator.validate(formData);
      // ...
    }

@loicdekester
Copy link
Author

Hi @elf-mouse,

Thanks for getting back to me so fast.

I see the problem, both in main.js and in components when we use the validator we have to get it from 'balm-ui/plugins/validator' for individual usage.

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

No branches or pull requests

2 participants