node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

typescript-validate

TypeScript Validation and Sanitization Decorators

Build Status npm version Coverage Status License Type

Getting Started

Using this package is simple and can be achevied with the following:

npm install typescript-validate

Contributing

Please contribute if you have any additions.

Quick Start

import { Sanitize, Validate, Sanitizor, Validator } from "typescript-validate";
 
class User {
 
    @Sanitize([
        SanitizationType.AlphaNumeric
    ])
    @Validate({
        String: {
            MinLength: 1,
            MaxLength: 5
        }
    })
    public Username: string;
 
    @Validate({
        CreditCard: [ CreditCardType.Mastercard, CreditCardType.Visa ]
    })
    private _creditCard: string;
}
 
var user = new User();
Sanitizor.Sanitize( user );
Validator.Valid( user );