Skip to content

vue-formily/rules

Repository files navigation


Validation rules for vue-formily.

Links

Installation

CDN

You can use validation rules with a script tag and a CDN, import the library like this:

<script src="https://unpkg.com/@vue-formily/rules@latest"></script>

This will inject a Rules global object, which you will use to access the various rules.

If you are using native ES Modules, there is also an ES Modules compatible build:

<script type="module">
  import rules from 'https://unpkg.com/@vue-formily/rules@latest/dist/rules.esm.js'
</script>

NPM

# install with yarn
yarn add @vue-formily/rules

# install with npm
npm install @vue-formily/rules --save

Basic Usage

import { required, email } from '@vue-formily/rules';

const formSchema = {
  formId: 'login',
  fields: [
    {
      formId: 'email',
      rules: [
        required,
        email
      ]
    },
  ]
};

// Use the schema in Vue instance
// ...

Contributing

You are welcome to contribute to this project, but before you do, please make sure you read the Contributing Guide.

License

MIT