import { registerDecorator , ValidationArguments , ValidationOptions } from 'class-validator' ; export function IsEqualTo ( property , validationOptions ? ) { return ( object , propertyName ) : any => { registerDecorator ( { name : 'isEqualTo' , target : object . constructor , propertyName , constraints : [ property ] , options : validationOptions , validator : { validate ( value , args ) { const [ relatedPropertyName ] = args . constraints ; const relatedValue = ( args . object as any ) [ relatedPropertyName ] ; return value === relatedValue ; } , defaultMessage ( args ) { const [ relatedPropertyName ] = args . constraints ; return `$property must match ${ relatedPropertyName } exactly` ; } , } , } ) ; } ; }