import { registerDecorator , ValidationOptions } from 'class-validator' ; export function SameAs ( property , validationOptions ? ) { return function ( object , propertyName ) { registerDecorator ( { name : 'sameAs' , target : object . constructor , propertyName : propertyName , options : validationOptions , constraints : [ property ] , validator : { validate ( value , args ) { const [ relatedPropertyName ] = args . constraints ; return args . object [ relatedPropertyName ] === value ; } , defaultMessage ( ) { return '$property must match $constraint1' ; } , } , } ) ; } ; }