@dzeio/schema 0.0.1 → 0.0.2

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/dist/Schema.d.mts CHANGED
@@ -43,6 +43,7 @@ declare abstract class SchemaItem<Type = any> implements StandardSchemaV1<Type>
43
43
  attr(...attributes: Array<string>): this;
44
44
  setInvalidError(err: string): this;
45
45
  clone(): this;
46
+ nullable(): SchemaNullable<this>;
46
47
  /**
47
48
  * schemas implementing unwrap can return their child component (mostly the value)
48
49
  *
@@ -83,6 +84,16 @@ type ValidationResult<T> = {
83
84
  errors: Array<ValidationError>
84
85
  }
85
86
 
87
+ type ValidationResultOld<T> = {
88
+ object: T
89
+ valid: true
90
+ error?: undefined
91
+ } | {
92
+ valid: false
93
+ object?: (T extends object ? Partial<T> : T) | undefined
94
+ error: Array<ValidationError>
95
+ }
96
+
86
97
  interface SchemaJSON {
87
98
  i: string
88
99
  a?: Array<string> | undefined
@@ -329,4 +340,4 @@ declare class Schema<T extends Record<string, SchemaItem> = Record<string, Schem
329
340
  }
330
341
  declare const s: typeof Schema;
331
342
 
332
- export { type Infer, type Model, type ModelInfer$1 as ModelInfer, SchemaArray, SchemaBoolean, SchemaDate, SchemaEnum, type SchemaInfer, SchemaItem, type SchemaItemJSON, type SchemaJSON, SchemaLiteral, SchemaNullable, SchemaNumber, SchemaObject, SchemaRecord, SchemaString, SchemaUnion, Types, type ValidationError, type ValidationResult, Schema as default, parceable, parseForm, parseFormData, parseQuery, s };
343
+ export { type Infer, type Model, type ModelInfer$1 as ModelInfer, SchemaArray, SchemaBoolean, SchemaDate, SchemaEnum, type SchemaInfer, SchemaItem, type SchemaItemJSON, type SchemaJSON, SchemaLiteral, SchemaNullable, SchemaNumber, SchemaObject, SchemaRecord, SchemaString, SchemaUnion, Types, type ValidationError, type ValidationResult, type ValidationResultOld, Schema as default, parceable, parseForm, parseFormData, parseQuery, s };
package/dist/Schema.d.ts CHANGED
@@ -43,6 +43,7 @@ declare abstract class SchemaItem<Type = any> implements StandardSchemaV1<Type>
43
43
  attr(...attributes: Array<string>): this;
44
44
  setInvalidError(err: string): this;
45
45
  clone(): this;
46
+ nullable(): SchemaNullable<this>;
46
47
  /**
47
48
  * schemas implementing unwrap can return their child component (mostly the value)
48
49
  *
@@ -83,6 +84,16 @@ type ValidationResult<T> = {
83
84
  errors: Array<ValidationError>
84
85
  }
85
86
 
87
+ type ValidationResultOld<T> = {
88
+ object: T
89
+ valid: true
90
+ error?: undefined
91
+ } | {
92
+ valid: false
93
+ object?: (T extends object ? Partial<T> : T) | undefined
94
+ error: Array<ValidationError>
95
+ }
96
+
86
97
  interface SchemaJSON {
87
98
  i: string
88
99
  a?: Array<string> | undefined
@@ -329,4 +340,4 @@ declare class Schema<T extends Record<string, SchemaItem> = Record<string, Schem
329
340
  }
330
341
  declare const s: typeof Schema;
331
342
 
332
- export { type Infer, type Model, type ModelInfer$1 as ModelInfer, SchemaArray, SchemaBoolean, SchemaDate, SchemaEnum, type SchemaInfer, SchemaItem, type SchemaItemJSON, type SchemaJSON, SchemaLiteral, SchemaNullable, SchemaNumber, SchemaObject, SchemaRecord, SchemaString, SchemaUnion, Types, type ValidationError, type ValidationResult, Schema as default, parceable, parseForm, parseFormData, parseQuery, s };
343
+ export { type Infer, type Model, type ModelInfer$1 as ModelInfer, SchemaArray, SchemaBoolean, SchemaDate, SchemaEnum, type SchemaInfer, SchemaItem, type SchemaItemJSON, type SchemaJSON, SchemaLiteral, SchemaNullable, SchemaNumber, SchemaObject, SchemaRecord, SchemaString, SchemaUnion, Types, type ValidationError, type ValidationResult, type ValidationResultOld, Schema as default, parceable, parseForm, parseFormData, parseQuery, s };
package/dist/Schema.js CHANGED
@@ -122,6 +122,9 @@ var SchemaItem = class _SchemaItem {
122
122
  clone() {
123
123
  return Schema.fromJSON(this.toJSON());
124
124
  }
125
+ nullable() {
126
+ return new SchemaNullable(this);
127
+ }
125
128
  parse(input, options) {
126
129
  var _a;
127
130
  for (const preProcess of this.preProcess) {
package/dist/Schema.mjs CHANGED
@@ -81,6 +81,9 @@ var SchemaItem = class _SchemaItem {
81
81
  clone() {
82
82
  return Schema.fromJSON(this.toJSON());
83
83
  }
84
+ nullable() {
85
+ return new SchemaNullable(this);
86
+ }
84
87
  parse(input, options) {
85
88
  var _a;
86
89
  for (const preProcess of this.preProcess) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzeio/schema",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "dependencies": {
5
5
  "@dzeio/object-util": "^1.8.3"
6
6
  },
@@ -37,6 +37,7 @@
37
37
  "scripts": {
38
38
  "test": "bun test",
39
39
  "lint": "eslint",
40
- "build": "rm -rf dist && tsup ./src/Schema.ts --format cjs,esm --dts --clean"
40
+ "build": "rm -rf dist && tsup ./src/Schema.ts --format cjs,esm --dts --clean",
41
+ "prepublishOnly": "rm -rf dist && tsup ./src/Schema.ts --format cjs,esm --dts --clean"
41
42
  }
42
43
  }