UNPKG

@sphereon/ssi-sdk.data-store

Version:

17 lines (13 loc) 602 B
import { type ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator' @ValidatorConstraint({ name: 'isNonEmptyString', async: false }) export class IsNonEmptyStringConstraint implements ValidatorConstraintInterface { validate(value: string, args: ValidationArguments): boolean { return !isEmptyString(value) } defaultMessage(args: ValidationArguments): string { return `${args.property} must not be an empty string.` } } export const isEmptyString = (value: any): boolean => { return typeof value === 'string' && value.trim().length === 0 }