import { isString , ValidateBy , ValidationOptions } from 'class-validator' ; export const IS_STRING_OR_REGEXP = 'IsStringOrRegExp' ; export function isStringOrRegExp ( values ) { return isString ( values ) || values instanceof RegExp ; } export class IsStringOrRegExpConstraint { validate ( values ) { return isStringOrRegExp ( values ) ; } defaultMessage ( ) { return 'The value must be a string or RegExp' ; } } export function IsStringOrRegExp ( validationOptions ? ) { return ValidateBy ( { name : IS_STRING_OR_REGEXP , constraints : [ ] , validator : new IsStringOrRegExpConstraint ( ) , } , validationOptions ) ; }