Wondering what’s next for npm?Check out our public roadmap! »

koatty_validation
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

koatty_validation

Validation 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);
})

Install

npm i koatty_validation

DownloadsWeekly Downloads

6

Version

1.0.0

License

MIT

Unpacked Size

96.8 kB

Total Files

14

Last publish

Collaborators

  • avatar