Skip to content

Commit 793c8b7

Browse files
author
Umed Khudoiberdiev
committed
refactored all validation classes, changed directory structure, removed deprecated methods, refactored index.ts and made validator async
1 parent 40eeb98 commit 793c8b7

25 files changed

+501
-527
lines changed

README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ Internally uses [validator.js][1] to perform validation.
55

66
## Release Notes
77

8+
**0.4.0** [BREAKING CHANGES]
9+
10+
* refactored all the code
11+
* everything should be imported from "class-validator" main entry point now
12+
* all validation decorators whose names was not prefixed with "Is" now are prefixed
13+
* fixed all decorators that should not work only with strings
14+
* added few more non-string decorators
15+
* validator now returns array of ValidationError instead of ValidationErrorInterface
16+
* removed all other validation methods expect `validator.valdate`
17+
* finally validate method is async now, so custom async validation types are supported now
18+
819
**0.3.0**
920

1021
* package has changed its name from `validator.ts` to `class-validator`.
@@ -16,11 +27,7 @@ Internally uses [validator.js][1] to perform validation.
1627

1728
`npm install class-validator --save`
1829

19-
2. Use [typings](https://github.com/typings/typings) to install all required definition dependencies.
20-
21-
`typings install`
22-
23-
3. ES6 features are used, so you may want to install [es6-shim](https://github.com/paulmillr/es6-shim) too:
30+
2. ES6 features are used, so you may want to install [es6-shim](https://github.com/paulmillr/es6-shim) too:
2431

2532
`npm install es6-shim --save`
2633

@@ -381,11 +388,6 @@ usages.
381388
to use it in production its highly recommended to fix library version that you use in your package.json file.
382389
Personally I use it in production.
383390

384-
## Release notes
385-
386-
**0.5.0**
387-
388-
389391
## Todos
390392

391393
* cover with tests

sample/sample1-simple-validation/Post.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {IsContain, IsInt, IsMinLength, IsMaxLength, IsEmail, IsFQDN, IsDate, IsNotEmpty, IsNotEmptyArray, IsMinSize, IsMaxSize} from "../../src/decorators";
1+
import {IsContain, IsInt, IsMinLength, IsMaxLength, IsEmail, IsFQDN, IsDate, IsNotEmpty, IsNotEmptyArray, IsMinSize, IsMaxSize} from "../../src/decorator/decorators";
22

33
export class Post {
44

sample/sample2-using-groups/Post.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {IsContain, IsInt, IsLength, IsEmail, IsFQDN, IsDate} from "../../src/decorators";
1+
import {IsContain, IsInt, IsLength, IsEmail, IsFQDN, IsDate} from "../../src/decorator/decorators";
22

33
export class Post {
44

sample/sample2-using-groups/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Validator} from "../../src/Validator";
1+
import {Validator} from "../../src/validation/Validator";
22
import {Post} from "./Post";
33

44
let validator = new Validator();

sample/sample3-nested-objects/Post.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {IsContain, IsInt, IsLength, IsEmail, IsFQDN, IsDate, NestedValidation} from "../../src/decorators";
1+
import {IsContain, IsInt, IsLength, IsEmail, IsFQDN, IsDate, NestedValidation} from "../../src/decorator/decorators";
22
import {Tag} from "./Tag";
33

44
export class Post {

sample/sample3-nested-objects/Tag.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {IsContain, IsInt, IsLength, IsEmail, IsFQDN, IsDate} from "../../src/decorators";
1+
import {IsContain, IsInt, IsLength, IsEmail, IsFQDN, IsDate} from "../../src/decorator/decorators";
22

33
export class Tag {
44

sample/sample3-nested-objects/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Validator} from "../../src/Validator";
1+
import {Validator} from "../../src/validation/Validator";
22
import {Post} from "./Post";
33
import {Tag} from "./Tag";
44

sample/sample4-custom-validator/CustomTextLength.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {ValidatorInterface} from "../../src/ValidatorInterface";
2-
import {ValidatorConstraint} from "../../src/decorators";
1+
import {CustomValidator} from "../../src/validation/CustomValidator";
2+
import {ValidatorConstraint} from "../../src/decorator/decorators";
33

44
@ValidatorConstraint()
5-
export class CustomTextLength implements ValidatorInterface {
5+
export class CustomTextLength implements CustomValidator {
66

77
validate(text: string): boolean {
88
return text.length > 1 && text.length < 10;

sample/sample4-custom-validator/Post.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {IsContain, IsInt, IsMinLength, IsMaxLength, IsEmail, IsFQDN, IsDate, IsNotEmpty, IsNotEmptyArray, IsMinSize, IsMaxSize} from "../../src/decorators";
2-
import {Validate} from "../../src/decorators";
1+
import {IsContain, IsInt, IsMinLength, IsMaxLength, IsEmail, IsFQDN, IsDate, IsNotEmpty, IsNotEmptyArray, IsMinSize, IsMaxSize} from "../../src/decorator/decorators";
2+
import {Validate} from "../../src/decorator/decorators";
33
import {CustomTextLength} from "./CustomTextLength";
44

55
export class Post {

sample/sample4-custom-validator/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Validator} from "../../src/Validator";
1+
import {Validator} from "../../src/validation/Validator";
22
import {Post} from "./Post";
33

44
let validator = new Validator();

src/ValidationError.ts

-15
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)