import { registerDecorator , ValidationOptions } from 'class-validator' ; export function validateCog ( value ) { if ( typeof value !== 'string' ) { return false ; } return /^(?:2[AB]|[0-9]{2})[0-9]{3}$/ . test ( value ) ; } param validationOptions export function IsCog ( validationOptions ? ) { return ( object , propertyName ) => { registerDecorator ( { name : 'isCog' , target : object . constructor , propertyName : propertyName , constraints : [ ] , options : validationOptions , validator : { validate : validateCog , } , } ) ; } ; }