Skip to content

Commit

Permalink
feat(Validator): add name type
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Nov 22, 2018
1 parent 3aafede commit 6bcfed7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import isNumeric from './isNumeric'
import isPromise from './isPromise'
import isRegExp from './isRegExp'
import isUrl from './isUrl'
import isChineseName from './isChineseName'

export type ValidatorRuleType = 'number' | 'integer' | 'phone' | 'mobile' | 'landline' | 'id' | 'url' | 'email'
export type ValidatorRuleType = 'number' | 'integer' | 'phone' | 'mobile' | 'landline' | 'id' | 'url' | 'email' | 'name'
export type ValidatorRuleTypePredicate = (value: any) => boolean
export type ValidatorRuleCustom = (
<D extends { [key: string]: any }>(payload: {
Expand Down Expand Up @@ -44,6 +45,7 @@ const typeValidators: { [key in ValidatorRuleType]: ValidatorRuleTypePredicate }
id: isChineseIDCardNumber,
url: isUrl,
email: isEmail,
name: isChineseName,
}

function validate<D>(data: D, key: keyof D, rule: ValidatorRule): Promise<boolean> {
Expand Down

0 comments on commit 6bcfed7

Please sign in to comment.