Created
May 24, 2017 00:56
-
-
Save stelcheck/914f2180221a39392d4620e22485a010 to your computer and use it in GitHub Desktop.
class-validator example
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
import {validate, Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, Min, Max} from "class-validator"; | |
export class Post { | |
@Length(10, 20) | |
title: string; | |
@Contains("hello") | |
text: string; | |
@IsInt() | |
@Min(0) | |
@Max(10) | |
rating: number; | |
@IsEmail() | |
email: string; | |
@IsFQDN() | |
site: string; | |
@IsDate() | |
createDate: Date; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment