GithubHelp home page GithubHelp logo

b-validate's People

Contributors

flsion avatar pengjiyuan avatar yinkaihui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

b-validate's Issues

国际化 i18n 支持

比如类似这种

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 可默认使用全局配置

schema.validate(data, callback),其中 callback 回调


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 是不是同步回调呢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.