Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
216 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": ["env"], | ||
"plugins": ["transform-runtime"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint no-console:0 */ | ||
|
||
import Schema from 'async-validator'; | ||
|
||
const schema = new Schema({ | ||
validator0: { | ||
asyncValidator(rule, value, callback) { | ||
setTimeout(() => callback('Validator0 message'), 100); | ||
}, | ||
}, | ||
validator1: { | ||
asyncValidator() { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => reject('Validator1 message'), 100); | ||
}); | ||
}, | ||
}, | ||
}); | ||
|
||
schema.validate({ | ||
validator0: '0', | ||
validator1: '1', | ||
}, (errors, fields) => { | ||
console.log('errors'); | ||
console.log(errors); | ||
console.log('fields'); | ||
console.log(fields); | ||
}); | ||
|
||
console.log('end'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* eslint no-console:0 no-unused-vars:0 */ | ||
|
||
import Schema from 'async-validator'; | ||
|
||
const schema = new Schema({ | ||
validator0: { | ||
validator(rule, value) { | ||
return true; | ||
}, | ||
}, | ||
validator1: { | ||
validator(rule, value) { | ||
return false; | ||
}, | ||
}, | ||
validator2: { | ||
validator(rule, value) { | ||
return false; | ||
}, | ||
message: 'Customize error messages', | ||
}, | ||
validator3: { | ||
validator(rule, value) { | ||
return [ | ||
'Error message 1', | ||
'Error message 2', | ||
'Error message 3', | ||
]; | ||
}, | ||
}, | ||
validator4: { | ||
validator(rule, value, callback) { | ||
setTimeout(() => callback('Compatible with older USES'), 100); | ||
}, | ||
}, | ||
}); | ||
|
||
schema.validate({ | ||
validator0: '0', | ||
validator1: '1', | ||
validator2: '2', | ||
validator3: '3', | ||
validator4: '4', | ||
}, (errors, fields) => { | ||
console.log('errors'); | ||
console.log(errors); | ||
console.log('fields'); | ||
console.log(fields); | ||
}); | ||
|
||
console.log('end'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import * as util from '../util'; | ||
|
||
const ENUM = 'enum'; | ||
|
||
/** | ||
|
Oops, something went wrong.