Compare commits
2 Commits
a0cc29169d
...
a7a20f55f4
Author | SHA1 | Date | |
---|---|---|---|
a7a20f55f4 | |||
cd59075921 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/schema",
|
"name": "@dzeio/schema",
|
||||||
"version": "0.0.6",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@dzeio/schema",
|
"name": "@dzeio/schema",
|
||||||
"version": "0.0.6",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dzeio/object-util": "^1.8.3",
|
"@dzeio/object-util": "^1.8.3",
|
||||||
"@standard-schema/spec": "^1.0.0",
|
"@standard-schema/spec": "^1.0.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/schema",
|
"name": "@dzeio/schema",
|
||||||
"version": "0.0.6",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dzeio/object-util": "^1.8.3"
|
"@dzeio/object-util": "^1.8.3"
|
||||||
},
|
},
|
||||||
|
@ -83,6 +83,17 @@ export default abstract class SchemaItem<Type = any> implements StandardSchemaV1
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make sure the value is one of the `values`
|
||||||
|
* @param values the values the item MUST contains
|
||||||
|
*/
|
||||||
|
@parceable()
|
||||||
|
public in(...values: Array<Type>): this {
|
||||||
|
this.addValidation((input) => values.includes(input))
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
public attrs(...attributes: Array<string>) {
|
public attrs(...attributes: Array<string>) {
|
||||||
this.attributes.concat(attributes)
|
this.attributes.concat(attributes)
|
||||||
return this
|
return this
|
||||||
|
@ -18,7 +18,7 @@ export default class SchemaEnum<E extends EnumLike> extends SchemaItem<E[keyof E
|
|||||||
this.type = 'number'
|
this.type = 'number'
|
||||||
}
|
}
|
||||||
|
|
||||||
// test above === numebr
|
// test above === number
|
||||||
this.validations.push({
|
this.validations.push({
|
||||||
fn: (input) => Object.values(this.templateEnum).includes(input),
|
fn: (input) => Object.values(this.templateEnum).includes(input),
|
||||||
error: `Input is not part of ${templateEnum.constructor.name}`
|
error: `Input is not part of ${templateEnum.constructor.name}`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user