Files
template-web-astro/src/libs/Schema/Items/SchemaFile.ts
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

22 lines
484 B
TypeScript

import SchemaItem from '../SchemaItem'
export default class SchemaFile extends SchemaItem<File> {
constructor () {
super()
this.parseActions.push((input) => this.isOfType(input) && input.size > 0 ? input : undefined)
}
public extension(ext: string, message?: string): this {
this.validations.push({
fn: (input) => input.name.endsWith(ext),
message
})
return this
}
public override isOfType(input: unknown): input is File {
return input instanceof File
}
}