koatty_validtion
v1.9.1
Published
Validtion Util for Koatty and ThinkORM.
Downloads
4
Readme
koatty_validtion
Validtion Util for Koatty and ThinkORM. Based on class-validator, extended parameter type checking and restricted attribute functions.
User Decorators
- @IsDefined
- @IsCnName
- @IsIdNumber
- @IsZipCode
- @IsMobile
- @IsPlateNumber
- @IsEmail
- @IsIP
- @IsPhoneNumber
- @IsUrl
- @IsHash
- @IsNotEmpty
- @Equals
- @NotEquals
- @Contains
- @IsIn
- @IsNotIn
- @IsDate
- @Min
- @Max
- @Length
Validator for manual
FunctionValidator
- FunctionValidator.IsCnName
- FunctionValidator.IsIdNumber
- FunctionValidator.IsZipCode
- FunctionValidator.IsMobile
- FunctionValidator.IsPlateNumber
- FunctionValidator.IsEmail
- FunctionValidator.IsIP
- FunctionValidator.IsPhoneNumber
- FunctionValidator.IsUrl
- FunctionValidator.IsHash
- FunctionValidator.IsNotEmpty
- FunctionValidator.Equals
- FunctionValidator.NotEquals
- FunctionValidator.Contains
- FunctionValidator.IsIn
- FunctionValidator.IsNotIn
- FunctionValidator.IsDate
- FunctionValidator.Min
- FunctionValidator.Max
- FunctionValidator.Length
if (!FunctionValidator.IsNotEmpty(data)) {
console.log('error');
}
ClassValidator
class SchemaClass {
@IsDefined
id: number;
@IsNotEmpty
name: string;
}
ClassValidator.valid(SchemaClass, {name: ''}).catch(err => {
console.log(err);
})