custom-class-validator-tools 1.1.21 → 1.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +45 -44
  2. package/readme.md +71 -71
package/package.json CHANGED
@@ -1,44 +1,45 @@
1
- {
2
- "name": "custom-class-validator-tools",
3
- "version": "1.1.21",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "typings": "dist/index.d.ts",
7
- "files": [
8
- "dist/*"
9
- ],
10
- "scripts": {
11
- "test": "jest",
12
- "test:coverage": "jest --coverage",
13
- "create:index": "just create:index",
14
- "build": "just build",
15
- "pub:npm": "just pub:npm"
16
- },
17
- "author": "internalservererror",
18
- "license": "MIT",
19
- "dependencies": {
20
- "class-transformer": "^0.5.1",
21
- "class-validator": "^0.14.0",
22
- "dayjs": "^1.11.10",
23
- "fp-ts": "^2.11.9"
24
- },
25
- "devDependencies": {
26
- "@eslint/eslintrc": "^3.0.2",
27
- "@eslint/js": "^9.2.0",
28
- "@types/jest": "^29.0.3",
29
- "@typescript-eslint/eslint-plugin": "^7.0.2",
30
- "@typescript-eslint/parser": "^7.0.2",
31
- "ctix": "^2.0.0",
32
- "eslint": "^9.2.0",
33
- "eslint-config-prettier": "^9.0.0",
34
- "eslint-plugin-import": "^2.28.1",
35
- "jest": "^29.6.0",
36
- "just-scripts": "^2.2.0",
37
- "prettier": "^3.0.0",
38
- "reflect-metadata": "^0.2.0",
39
- "ts-jest": "^29.1.0",
40
- "ts-node": "^10.7.0",
41
- "tsc-alias": "^1.6.7",
42
- "typescript": "^5.0.2"
43
- }
44
- }
1
+ {
2
+ "name": "custom-class-validator-tools",
3
+ "version": "1.1.23",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/*"
9
+ ],
10
+ "scripts": {
11
+ "test": "jest",
12
+ "test:coverage": "jest --coverage",
13
+ "create:index": "just create:index",
14
+ "build": "just build",
15
+ "pub:npm": "just pub:npm"
16
+ },
17
+ "author": "internalservererror",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "class-transformer": "^0.5.1",
21
+ "class-validator": "^0.14.0",
22
+ "dayjs": "^1.11.10",
23
+ "fp-ts": "^2.11.9"
24
+ },
25
+ "devDependencies": {
26
+ "@eslint/eslintrc": "^3.1.0",
27
+ "@eslint/js": "^9.3.0",
28
+ "@types/jest": "^29.0.3",
29
+ "@typescript-eslint/eslint-plugin": "^7.10.0",
30
+ "@typescript-eslint/parser": "^7.0.2",
31
+ "ajv": "^8.13.0",
32
+ "ctix": "^2.0.0",
33
+ "eslint": "^9.3.0",
34
+ "eslint-config-prettier": "^9.0.0",
35
+ "eslint-plugin-import": "^2.28.1",
36
+ "jest": "^29.6.0",
37
+ "just-scripts": "^2.2.0",
38
+ "prettier": "^3.0.0",
39
+ "reflect-metadata": "^0.2.0",
40
+ "ts-jest": "^29.1.0",
41
+ "ts-node": "^10.7.0",
42
+ "tsc-alias": "^1.6.7",
43
+ "typescript": "^5.0.2"
44
+ }
45
+ }
package/readme.md CHANGED
@@ -1,71 +1,71 @@
1
- ## String type decorator
2
-
3
-
4
- | Decorator | Type | Description|
5
- | --- | --- | --- |
6
- | @IsNullableString | string | null | If want to ignore value ≠= ‘’, @IsNullableString({ blank: true }) |
7
- | @IsUndefinableString | string | undefined | If want to ignore value ≠= ‘’, @IsUndefinableString({ blank: true }) |
8
- | @IsOptionalString | string | null | undefined | If want to ignore value ≠= ‘’, @IsOptionalString({ blank: true }) |
9
- | @IsNotEmptyNumberString | string | Checks a string is a number |
10
- | @IsNotEmptyBooleanString | string | Checks a string is a boolean |
11
- | @IsNullableNumberString | string | null | Checks a string is a number or null |
12
- | @IsNullableBooleanString | string | null | Checks a string is a boolean or null |
13
- | @IsUndefinableNumberString | string | undefined | Checks a string is a number or undefined |
14
- | @IsUndefinableBooleanString | string | undefined | Checks a string is a boolean or null |
15
- | @IsOptionalNumberString | string | null | undefined | Checks a string is a number or null or undefined |
16
- | @IsOptionalBooleanString | string | null | undefined | Checks a string is a boolean or null or undefined |
17
-
18
- ## Number type decorator
19
-
20
-
21
- | Decorator | Type |
22
- |----------------------|--------|
23
- | @IsNotEmptyNumber | number |
24
- | @IsNullableNumber | nubmer | null |
25
- | @IsUndefinableNumber | number | undefined |
26
- | @IsOptionalNumber | number | null | undefined |
27
- | | |
28
-
29
- ## Boolean type decorator
30
-
31
- | Decorator | Type |
32
- | --- | --- |
33
- | @IsNotEmptyBoolean | boolean |
34
- | @IsNullableBoolean | boolean | null |
35
- | @IsUndefinalbeBoolean | boolean | undefined |
36
- | @IsOptionalBoolean | boolean | null | undefined |
37
-
38
- ## ValidateNested usage case
39
-
40
- ```ts
41
- import { isNotEmptyString, IsNotEmptyBoolean, isNullable, IsUndefinable } from 'custom-class-validator-tools';
42
- import { IsInstance, ArrayNotEmpty, ValidateNested } from 'class-validator';
43
- import { Type } from 'class-transformer';
44
-
45
- class Tag {
46
- @IsNotEmptyString()
47
- tag1: string;
48
- @IsNotEmptyString()
49
- tag2: string;
50
- }
51
-
52
- class Result {
53
- @IsNotEmptyBoolean()
54
- failed: boolean;
55
- }
56
-
57
- class Post {
58
- @IsNullable()
59
- @ArrayNotEmpty()
60
- @IsInstance(Tag, { each: true })
61
- @ValidateNested({ each: true })
62
- @Type(() => Tag)
63
- tags: Tag[] | null;
64
-
65
- @IsUndefinable()
66
- @IsInstance(Result)
67
- @ValidateNested()
68
- @Type(() => Result)
69
- result?: Result;
70
- }
71
- ```
1
+ ## String type decorator
2
+
3
+
4
+ | Decorator | Type | Description|
5
+ | --- | --- | --- |
6
+ | @IsNullableString | string | null | If want to ignore value ≠= ‘’, @IsNullableString({ blank: true }) |
7
+ | @IsUndefinableString | string | undefined | If want to ignore value ≠= ‘’, @IsUndefinableString({ blank: true }) |
8
+ | @IsOptionalString | string | null | undefined | If want to ignore value ≠= ‘’, @IsOptionalString({ blank: true }) |
9
+ | @IsNotEmptyNumberString | string | Checks a string is a number |
10
+ | @IsNotEmptyBooleanString | string | Checks a string is a boolean |
11
+ | @IsNullableNumberString | string | null | Checks a string is a number or null |
12
+ | @IsNullableBooleanString | string | null | Checks a string is a boolean or null |
13
+ | @IsUndefinableNumberString | string | undefined | Checks a string is a number or undefined |
14
+ | @IsUndefinableBooleanString | string | undefined | Checks a string is a boolean or null |
15
+ | @IsOptionalNumberString | string | null | undefined | Checks a string is a number or null or undefined |
16
+ | @IsOptionalBooleanString | string | null | undefined | Checks a string is a boolean or null or undefined |
17
+
18
+ ## Number type decorator
19
+
20
+
21
+ | Decorator | Type |
22
+ |----------------------|--------|
23
+ | @IsNotEmptyNumber | number |
24
+ | @IsNullableNumber | nubmer | null |
25
+ | @IsUndefinableNumber | number | undefined |
26
+ | @IsOptionalNumber | number | null | undefined |
27
+ | | |
28
+
29
+ ## Boolean type decorator
30
+
31
+ | Decorator | Type |
32
+ | --- | --- |
33
+ | @IsNotEmptyBoolean | boolean |
34
+ | @IsNullableBoolean | boolean | null |
35
+ | @IsUndefinalbeBoolean | boolean | undefined |
36
+ | @IsOptionalBoolean | boolean | null | undefined |
37
+
38
+ ## ValidateNested usage case
39
+
40
+ ```ts
41
+ import { isNotEmptyString, IsNotEmptyBoolean, isNullable, IsUndefinable } from 'custom-class-validator-tools';
42
+ import { IsInstance, ArrayNotEmpty, ValidateNested } from 'class-validator';
43
+ import { Type } from 'class-transformer';
44
+
45
+ class Tag {
46
+ @IsNotEmptyString()
47
+ tag1: string;
48
+ @IsNotEmptyString()
49
+ tag2: string;
50
+ }
51
+
52
+ class Result {
53
+ @IsNotEmptyBoolean()
54
+ failed: boolean;
55
+ }
56
+
57
+ class Post {
58
+ @IsNullable()
59
+ @ArrayNotEmpty()
60
+ @IsInstance(Tag, { each: true })
61
+ @ValidateNested({ each: true })
62
+ @Type(() => Tag)
63
+ tags: Tag[] | null;
64
+
65
+ @IsUndefinable()
66
+ @IsInstance(Result)
67
+ @ValidateNested()
68
+ @Type(() => Result)
69
+ result?: Result;
70
+ }
71
+ ```