@dzeio/schema 0.0.6 → 0.1.0

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
@@ -40,6 +40,11 @@ declare abstract class SchemaItem<Type = any> implements StandardSchemaV1<Type>
40
40
  private invalidError;
41
41
  constructor(items?: Array<unknown> | IArguments);
42
42
  defaultValue(value: Type, strict?: boolean): this;
43
+ /**
44
+ * make sure the value is one of the `values`
45
+ * @param values the values the item MUST contains
46
+ */
47
+ in(...values: Array<Type>): this;
43
48
  attrs(...attributes: Array<string>): this;
44
49
  attr(...attributes: Array<string>): this;
45
50
  setInvalidError(err: string): this;
package/dist/Schema.d.ts CHANGED
@@ -40,6 +40,11 @@ declare abstract class SchemaItem<Type = any> implements StandardSchemaV1<Type>
40
40
  private invalidError;
41
41
  constructor(items?: Array<unknown> | IArguments);
42
42
  defaultValue(value: Type, strict?: boolean): this;
43
+ /**
44
+ * make sure the value is one of the `values`
45
+ * @param values the values the item MUST contains
46
+ */
47
+ in(...values: Array<Type>): this;
43
48
  attrs(...attributes: Array<string>): this;
44
49
  attr(...attributes: Array<string>): this;
45
50
  setInvalidError(err: string): this;
package/dist/Schema.js CHANGED
@@ -119,6 +119,10 @@ var _SchemaItem = class _SchemaItem {
119
119
  });
120
120
  return this;
121
121
  }
122
+ in(...values) {
123
+ this.addValidation((input) => values.includes(input));
124
+ return this;
125
+ }
122
126
  attrs(...attributes) {
123
127
  this.attributes.concat(attributes);
124
128
  return this;
@@ -205,6 +209,9 @@ var _SchemaItem = class _SchemaItem {
205
209
  __decorateClass([
206
210
  parceable()
207
211
  ], _SchemaItem.prototype, "defaultValue", 1);
212
+ __decorateClass([
213
+ parceable()
214
+ ], _SchemaItem.prototype, "in", 1);
208
215
  var SchemaItem = _SchemaItem;
209
216
 
210
217
  // src/items/array.ts
package/dist/Schema.mjs CHANGED
@@ -76,6 +76,10 @@ var _SchemaItem = class _SchemaItem {
76
76
  });
77
77
  return this;
78
78
  }
79
+ in(...values) {
80
+ this.addValidation((input) => values.includes(input));
81
+ return this;
82
+ }
79
83
  attrs(...attributes) {
80
84
  this.attributes.concat(attributes);
81
85
  return this;
@@ -162,6 +166,9 @@ var _SchemaItem = class _SchemaItem {
162
166
  __decorateClass([
163
167
  parceable()
164
168
  ], _SchemaItem.prototype, "defaultValue", 1);
169
+ __decorateClass([
170
+ parceable()
171
+ ], _SchemaItem.prototype, "in", 1);
165
172
  var SchemaItem = _SchemaItem;
166
173
 
167
174
  // src/items/array.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzeio/schema",
3
- "version": "0.0.6",
3
+ "version": "0.1.0",
4
4
  "dependencies": {
5
5
  "@dzeio/object-util": "^1.8.3"
6
6
  },