import { registerDecorator , ValidationArguments , ValidationOptions , ValidatorConstraint , ValidatorConstraintInterface } from 'class-validator' ; @ ValidatorConstraint ( { async : false } ) export class CannotWithConstraint implements ValidatorConstraintInterface { validate ( _value , { constraints , ... args } ) { const object = args . object as any ; return constraints . every ( constraint => ! object [ constraint ] ) ; } defaultMessage ( { property , constraints } ) { const join = constraints . join ( ', ' ) ; return `${ property } cannot be used with ${ join }` ; } } export function CannotWith ( props , options ? ) { return function ( { constructor : target } , propertyName ) : void { registerDecorator ( { target , propertyName , options , constraints : props , validator : CannotWithConstraint } ) ; } ; }