-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
283 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, ValidateNested} from "../../src/decorator/decorators"; | ||
import {Tag} from "./Tag"; | ||
|
||
export class Post { | ||
|
||
@Length(10, 20, { | ||
message: "Incorrect length!" | ||
}) | ||
title: string; | ||
|
||
@ValidateNested() | ||
tags: Map<string, Tag>; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {Contains, IsInt, Length, IsEmail, IsFQDN, IsDate} from "../../src/decorator/decorators"; | ||
|
||
export class Tag { | ||
|
||
@Length(10, 20, { | ||
message: "Tag value is too short or long" | ||
}) | ||
value: string; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {Validator} from "../../src/validation/Validator"; | ||
import {Post} from "./Post"; | ||
import {Tag} from "./Tag"; | ||
|
||
let validator = new Validator(); | ||
|
||
let tag1 = new Tag(); | ||
tag1.value = "ja"; | ||
|
||
let tag2 = new Tag(); | ||
tag2.value = "node.js"; | ||
|
||
let post1 = new Post(); | ||
post1.title = "Hello world"; | ||
post1.tags = new Map(); | ||
post1.tags.set("tag1", tag1); | ||
post1.tags.set("tag2", tag2); | ||
|
||
validator.validate(post1).then(result => { | ||
console.log("1. should not pass: ", result); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, ValidateNested} from "../../src/decorator/decorators"; | ||
import {Tag} from "./Tag"; | ||
|
||
export class Post { | ||
|
||
@Length(10, 20, { | ||
message: "Incorrect length!" | ||
}) | ||
title: string; | ||
|
||
@ValidateNested() | ||
tags: Set<Tag>; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {Contains, IsInt, Length, IsEmail, IsFQDN, IsDate} from "../../src/decorator/decorators"; | ||
|
||
export class Tag { | ||
|
||
@Length(10, 20, { | ||
message: "Tag value is too short or long" | ||
}) | ||
value: string; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {Validator} from "../../src/validation/Validator"; | ||
import {Post} from "./Post"; | ||
import {Tag} from "./Tag"; | ||
|
||
let validator = new Validator(); | ||
|
||
let tag1 = new Tag(); | ||
tag1.value = "ja"; | ||
|
||
let tag2 = new Tag(); | ||
tag2.value = "node.js"; | ||
|
||
let post1 = new Post(); | ||
post1.title = "Hello world"; | ||
post1.tags = new Set(); | ||
post1.tags.add(tag1); | ||
post1.tags.add(tag2); | ||
|
||
validator.validate(post1).then(result => { | ||
console.log("1. should not pass: ", result); | ||
}); |
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
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