import { buildMessage , isEmail , ValidateBy } from 'class-validator' ; export function IsEmailOrEmpty ( ) { return ValidateBy ( { name : 'isEmailOrEmpty' , validator : { validate : value => { return value === '' || isEmail ( value ) ; } , defaultMessage : buildMessage ( eachPrefix => eachPrefix + '$property must be an email' ) } } ) ; }