import { isAscii , isObject , ValidateBy , ValidationOptions , } from 'class-validator' ; export const VALIDATE_HTTP_HEADERS = 'ValidateHttpHeaders' ; export function isHttpHeaders ( values ) { const params = Object . entries ( values ) ; const check = params . every ( ( [ key , value ] ) => isAscii ( key ) && isAscii ( value ) ) ; return check ; } export class ValidateHttpHeadersConstraint { validate ( values ) { return isObject ( values ) && isHttpHeaders ( values ) ; } defaultMessage ( ) { return 'Please check the HTTP headers values' ; } } export function ValidateHttpHeaders ( validationOptions ? ) { return ValidateBy ( { name : VALIDATE_HTTP_HEADERS , constraints : [ ] , validator : new ValidateHttpHeadersConstraint ( ) , } , validationOptions ) ; }