@hg-ts/validation 0.1.54 → 0.1.55
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.
- package/package.json +4 -4
- package/.eslintcache +0 -1
- package/.turbo/turbo-build.log +0 -2
- package/.turbo/turbo-lint$colon$ts.log +0 -2
- package/.turbo/turbo-test.log +0 -9
- package/src/dto.ts +0 -26
- package/src/extensions.ts +0 -45
- package/src/index.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hg-ts/validation",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.55",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js"
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"test:dev": "yarn build:dev --onSuccess \"yarn test\""
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@hg-ts-config/typescript": "0.1.
|
|
20
|
-
"@hg-ts/linter": "0.1.
|
|
21
|
-
"@hg-ts/types": "0.1.
|
|
19
|
+
"@hg-ts-config/typescript": "0.1.55",
|
|
20
|
+
"@hg-ts/linter": "0.1.55",
|
|
21
|
+
"@hg-ts/types": "0.1.55",
|
|
22
22
|
"@types/node": "22.10.6",
|
|
23
23
|
"eslint": "9.18.0",
|
|
24
24
|
"reflect-metadata": "0.2.2",
|
package/.eslintcache
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/dto.js":"1","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/extensions.js":"2","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/index.js":"3","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/eslint.config.mjs":"4","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/dto.ts":"5","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/extensions.ts":"6","/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/index.ts":"7"},{"size":391,"mtime":1746294775585,"results":"8","hashOfConfig":"9"},{"size":679,"mtime":1746294775589,"results":"10","hashOfConfig":"9"},{"size":304,"mtime":1746294775592,"results":"11","hashOfConfig":"9"},{"size":59,"mtime":1736896000120,"results":"12","hashOfConfig":"9"},{"size":595,"mtime":1736876770680,"results":"13","hashOfConfig":"14"},{"size":1328,"mtime":1736893489221,"results":"15","hashOfConfig":"14"},{"size":88,"mtime":1736876770680,"results":"16","hashOfConfig":"14"},{"filePath":"17","messages":"18","suppressedMessages":"19","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1gtnk1i",{"filePath":"20","messages":"21","suppressedMessages":"22","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"23","messages":"24","suppressedMessages":"25","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"26","messages":"27","suppressedMessages":"28","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"29","messages":"30","suppressedMessages":"31","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"i5df87",{"filePath":"32","messages":"33","suppressedMessages":"34","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"35","messages":"36","suppressedMessages":"37","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/dto.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/extensions.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/dist/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/eslint.config.mjs",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/dto.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/extensions.ts",[],["38"],"/Users/atsapko/WebstormProjects/personnal/framework/packages/validation/src/index.ts",[],[],{"ruleId":"39","severity":2,"message":"40","line":17,"column":12,"nodeType":"41","messageId":"42","endLine":17,"endColumn":21,"fix":"43","suppressions":"44"},"@typescript/consistent-type-definitions","Use a `type` instead of an `interface`.","Identifier","typeOverInterface",{"range":"45","text":"46"},["47"],[276,363],"type ZodSchema<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> = ",{"kind":"48","justification":"49"},"directive",""]
|
package/.turbo/turbo-build.log
DELETED
package/.turbo/turbo-test.log
DELETED
package/src/dto.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ZodSchema,
|
|
3
|
-
ZodTypeDef,
|
|
4
|
-
} from 'zod';
|
|
5
|
-
|
|
6
|
-
export type ZodDto<TOutput = any> = {
|
|
7
|
-
new (): TOutput;
|
|
8
|
-
isZodDto: true;
|
|
9
|
-
schema: ZodSchema<TOutput, ZodTypeDef, unknown>;
|
|
10
|
-
create(input: unknown): TOutput;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function createZodDto<TOutput = any>(
|
|
14
|
-
schema: ZodSchema<TOutput, ZodTypeDef, unknown>,
|
|
15
|
-
): ZodDto<TOutput> {
|
|
16
|
-
class AugmentedZodDto {
|
|
17
|
-
public static isZodDto = true;
|
|
18
|
-
public static schema = schema;
|
|
19
|
-
|
|
20
|
-
public static create(input: unknown): AugmentedZodDto {
|
|
21
|
-
return this.schema.parse(input) as AugmentedZodDto;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return AugmentedZodDto as unknown as ZodDto<TOutput>;
|
|
26
|
-
}
|
package/src/extensions.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import zod, {
|
|
2
|
-
ZodEffects,
|
|
3
|
-
ZodSchema,
|
|
4
|
-
ZodTypeDef,
|
|
5
|
-
infer as ZodInfer,
|
|
6
|
-
input as ZodInput,
|
|
7
|
-
ZodPipeline,
|
|
8
|
-
ZodBoolean,
|
|
9
|
-
} from 'zod';
|
|
10
|
-
import {
|
|
11
|
-
createZodDto,
|
|
12
|
-
ZodDto,
|
|
13
|
-
} from './dto';
|
|
14
|
-
|
|
15
|
-
declare module 'zod' {
|
|
16
|
-
// eslint-disable-next-line @typescript/consistent-type-definitions
|
|
17
|
-
interface ZodSchema<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
|
|
18
|
-
enforceEnv<T extends ZodSchema<Output, Def, Input>>(this: T, name: string): ZodEffects<T, ZodInfer<T> | string>;
|
|
19
|
-
transformBooleanString<T extends ZodSchema<Output, Def, Input>>(
|
|
20
|
-
this: T,
|
|
21
|
-
): ZodPipeline<ZodEffects<T, boolean, ZodInput<T>>, ZodBoolean>;
|
|
22
|
-
toClass<T extends ZodSchema<Output, Def, Input>>(this: T): ZodDto<ZodInfer<T>>;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
zod.Schema.prototype.enforceEnv = function<T extends ZodSchema>(
|
|
27
|
-
this: T,
|
|
28
|
-
name: string,
|
|
29
|
-
): ZodEffects<T, ZodInfer<T> | string> {
|
|
30
|
-
return this.transform(value => process.env[name] ?? value);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
zod.Schema.prototype.transformBooleanString = function<T extends ZodSchema>(
|
|
34
|
-
this: T,
|
|
35
|
-
): ZodPipeline<zod.ZodEffects<T, boolean, ZodInput<T>>, ZodBoolean> {
|
|
36
|
-
return this
|
|
37
|
-
.transform(value => (typeof value === 'boolean' ? value : value === 'true'))
|
|
38
|
-
.pipe(zod.boolean());
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
zod.Schema.prototype.toClass = function<T extends ZodSchema>(
|
|
42
|
-
this: T,
|
|
43
|
-
): ZodDto<ZodInfer<T>> {
|
|
44
|
-
return createZodDto<ZodInfer<T>>(this);
|
|
45
|
-
};
|