pengjiyuan / b-validate Goto Github PK
View Code? Open in Web Editor NEW:eyes: Tiny and powerful Javascript type validate.
License: MIT License
:eyes: Tiny and powerful Javascript type validate.
License: MIT License
比如类似这种
default(en_US):
{
"required": "{field} is required"
}
zh_CN:
{
"required": "{field} 必填"
}
或者是
default(en_US):
{
"required": "required"
}
zh_CN:
{
"required": "必填"
}
全局配置
main.ts
import bv from 'b-validate'
import zhCN from 'b-validate/locale/zhCN'
bv.setupGlobalLocale(zhCN)
之后其他地方配置的 rules 可默认使用全局配置
Line 21 in 168fed2
number
, add closed interval setting
schema.validate({
name: 'pengjiyuan is a nice boy',
age: 24,
email: '[email protected]',
ip: '127.0.0.1',
url: 'https://bytedancecom',
custom: 20,
async: 20
}, (errors) => {
console.log(errors);
/*
* {
* value: 'pengjiyuan is a nice boy', type: 'string', message: '最大长度是10' },
* age: { value: 24, type: 'number', message: '在2和5之间' },
* url: { value: 'https://bytedancecom', type: 'url', message: 'url格式不对' },
* custom: { value: 20, type: 'custom', message: '不能大于10!' }
* }
*/
});
schema.validate(data, callback),如果 schema 中没有 asyncValidate 那么 callback 是不是同步回调呢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.