Florian Bouillon bc97d9106b
Some checks failed
Build, check & Test / run (push) Failing after 1m45s
Lint / run (push) Failing after 48s
Build Docker Image / build_docker (push) Failing after 3m18s
feat: Filemagedon
Signed-off-by: Avior <git@avior.me>
2024-09-11 14:38:58 +02:00

24 lines
489 B
TypeScript

import SchemaItem, { type JSONSchemaItem } from '../SchemaItem'
export default class DzeioLiteral<T> extends SchemaItem<T> {
public constructor(private readonly value: T) {
super()
this.validations.push({
fn(input) {
return input === value
}
})
}
public override isOfType(input: unknown): input is T {
return typeof input === typeof this.value
}
public override toJSON(): JSONSchemaItem {
return {
type: 'literal',
params: [this.value as string]
}
}
}