From cb71f36aefefcf785daba7149d9ef81d5b6c539c Mon Sep 17 00:00:00 2001 From: adamcikado Date: Mon, 29 Apr 2024 12:52:17 +0200 Subject: [PATCH] feat: export modifiers --- package.json | 3 ++- src/schema/base/literal.ts | 10 +++++++--- src/schema/base/main.ts | 8 ++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 66e324b..2d5e401 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ ".": "./build/index.js", "./defaults": "./build/src/defaults.js", "./factories": "./build/factories/main.js", - "./types": "./build/src/types.js" + "./types": "./build/src/types.js", + "./schema/base/*": "./build/src/schema/base/*.js" }, "scripts": { "pretest": "npm run lint", diff --git a/src/schema/base/literal.ts b/src/schema/base/literal.ts index 83aced8..efade13 100644 --- a/src/schema/base/literal.ts +++ b/src/schema/base/literal.ts @@ -91,7 +91,9 @@ abstract class BaseModifiersType /** * Modifies the schema type to allow null values */ -class NullableModifier> extends BaseModifiersType< +export class NullableModifier< + Schema extends BaseModifiersType, +> extends BaseModifiersType< Schema[typeof ITYPE] | null, Schema[typeof OTYPE] | null, Schema[typeof COTYPE] | null @@ -124,7 +126,9 @@ class NullableModifier> extends /** * Modifies the schema type to allow undefined values */ -class OptionalModifier> extends BaseModifiersType< +export class OptionalModifier< + Schema extends BaseModifiersType, +> extends BaseModifiersType< Schema[typeof ITYPE] | undefined | null, Schema[typeof OTYPE] | undefined, Schema[typeof COTYPE] | undefined @@ -334,7 +338,7 @@ class OptionalModifier> extends /** * Modifies the schema type to allow custom transformed values */ -class TransformModifier< +export class TransformModifier< Schema extends BaseModifiersType, Output, > extends BaseModifiersType { diff --git a/src/schema/base/main.ts b/src/schema/base/main.ts index 48a21b3..63c1129 100644 --- a/src/schema/base/main.ts +++ b/src/schema/base/main.ts @@ -73,7 +73,9 @@ export abstract class BaseModifiersType /** * Modifies the schema type to allow null values */ -class NullableModifier> extends BaseModifiersType< +export class NullableModifier< + Schema extends BaseModifiersType, +> extends BaseModifiersType< Schema[typeof ITYPE] | null, Schema[typeof OTYPE] | null, Schema[typeof COTYPE] | null @@ -108,7 +110,9 @@ class NullableModifier> extends /** * Modifies the schema type to allow undefined values */ -class OptionalModifier> extends BaseModifiersType< +export class OptionalModifier< + Schema extends BaseModifiersType, +> extends BaseModifiersType< Schema[typeof ITYPE] | undefined | null, Schema[typeof OTYPE] | undefined, Schema[typeof COTYPE] | undefined