1 Star 0 Fork 1

RZ / vee-validate

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

codecov Build Status Codacy Badge CDNJS npm npm Average time to resolve an issue Percentage of issues still open


Proudly sponsored by:



vee-validate is a lightweight plugin for Vue.js that allows you to validate input fields, and display errors.

What makes it different is: You don't have to do anything fancy in your app, most of the work goes into the html, You only need to specify for each input what kind of validators should be used when the value changes. The errors will be automatically generated. The plugin offers many validations out of the box.

Although most of the validations occur automatically, you can use the validator however you see fit. The validator object has no dependencies and is a standalone object. This plugin is built with localization in mind. Read the docs for more info.

This plugin is inspired by PHP Framework Laravel's validation.

Installation

npm

npm install vee-validate --save

or if you are using Vue 1.0 (deprecated) :

npm install vee-validate@prev --save

Note: Vue 1.0 version is currently deprecated and does not have the latest features and fixes.

bower

bower install vee-validate#2.0.0-rc.3 --save

CDN

vee-validate is also available on jsdelivr cdn:

select whatever version you would like to use.

Getting Started

In your script entry point:

import Vue from 'vue';
import VeeValidate from 'vee-validate';

Vue.use(VeeValidate);

Now you are all setup to use the plugin.

Usage

Just apply the v-validate directive on your input and pass a string value which is a list of validations separated by a pipe, for example we will use the required and the email validators:

<input v-validate="'required|email'" type="text" name="email">

You can also pass an object for more flexibility:

<input v-validate="{ rules: { required: true, email: true } }" type="text" name="email">

Now every time the input changes, the validator will run the list of validations from left to right, populating the errors helper object whenever an input fails validation.

To access the errors object (in your vue instance):

this.$validator.errorBag;
// or
this.errors; // injected into $data by the plugin, you can customize the property name.

so lets display the error for the email input we've created:

<!-- If it has an email error, display the first message associated with it. -->
<span v-show="errors.has('email')">{{ errors.first('email') }}</span>

Of course there is more to it than that, refer to the documentation for more details about the rules, and usage of this plugin.

Documentation

Read the documentation and demos.

Contributing

You are welcome to contribute to this repo with anything you think is useful. fixes are more than welcome. However if you are adding a new validation rule, it should have multiple uses or as generic as possible.

You can find more information in the contribution guide.

Tutorials and Examples

Credits

Roadmap

  • First Full Release (Out of beta) - Mid May 2017
  • Vuex Support - Late May / Mid June 2017

license MIT

The MIT License (MIT) Copyright (c) Abdelrahman Awad <logaretm1@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

vee-validate is a lightweight plugin for Vue.js that allows you to validate input fields, and display errors. 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/uygurjan2008/vee-validate.git
git@gitee.com:uygurjan2008/vee-validate.git
uygurjan2008
vee-validate
vee-validate
master

搜索帮助