feat: add the in
check
This commit is contained in:
parent
a0cc29169d
commit
cd59075921
@ -83,6 +83,17 @@ export default abstract class SchemaItem<Type = any> implements StandardSchemaV1
|
||||
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>) {
|
||||
this.attributes.concat(attributes)
|
||||
return this
|
||||
|
@ -18,7 +18,7 @@ export default class SchemaEnum<E extends EnumLike> extends SchemaItem<E[keyof E
|
||||
this.type = 'number'
|
||||
}
|
||||
|
||||
// test above === numebr
|
||||
// test above === number
|
||||
this.validations.push({
|
||||
fn: (input) => Object.values(this.templateEnum).includes(input),
|
||||
error: `Input is not part of ${templateEnum.constructor.name}`
|
||||
|
Loading…
x
Reference in New Issue
Block a user