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

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

Open
gaowujie2004 opened this issue Aug 19, 2022 · 0 comments
Open

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

gaowujie2004 opened this issue Aug 19, 2022 · 0 comments

Comments

@gaowujie2004
Copy link


schema.validate({
  name: 'pengjiyuan is a nice boy',
  age: 24,
  email: 'pengjiyuan@bytedance.com',
  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 是不是同步回调呢

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

1 participant