import { RequiredFieldError } from '@/application/errors' ; import { Validator } from '@/application/validation' ; export class Required implements Validator { constructor ( readonly value , readonly fieldName ? ) { } validate ( ) { if ( this . value === null || this . value === undefined ) { return new RequiredFieldError ( this . fieldName ) ; } } } export class RequiredString extends Required { constructor ( override readonly value , override readonly fieldName ? ) { super ( value , fieldName ) ; } override validate ( ) { if ( super . validate ( ) !== undefined || this . value === '' ) { return new RequiredFieldError ( this . fieldName ) ; } } } export class RequiredBuffer extends Required { constructor ( override readonly value , override readonly fieldName ? ) { super ( value , fieldName ) ; } override validate ( ) { if ( super . validate ( ) !== undefined || this . value . length === 0 ) { return new RequiredFieldError ( this . fieldName ) ; } } }