Headers decoder with type validation (for express and fastify).
typia.http.validateHeaders() is a function decoding an header instance, with
automatic type casting to the expected type. When property type be defined as
boolean or number type, typia.http.headers() will cast the value to the
expected type.
Also, after decoding, typia.http.validateHeaders() performs type assertion to the
decoded value by combining with validate function. Therefore, when the
decoded value is not following the T type, IValidation.IError would be
returned. Otherwise, IValidation.ISuccess be returned.
By the way, as HTTP headers are not enough to express complex data structures,
typia.http.headers() function has some limitations. If target type T is not
following those restrictions, compilation errors would be occured.
Type T must be an object type
Do not allow dynamic property
Property key must be lower case
Property value cannot be null, but undefined is possible
Only boolean, bigint, number, string or their array types are allowed
Headers decoder with type validation (for express and fastify).
typia.http.validateHeaders()
is a function decoding an header instance, with automatic type casting to the expected type. When property type be defined asboolean
ornumber
type,typia.http.headers()
will cast the value to the expected type.Also, after decoding,
typia.http.validateHeaders()
performs type assertion to the decoded value by combining with validate function. Therefore, when the decoded value is not following theT
type, IValidation.IError would be returned. Otherwise, IValidation.ISuccess be returned.By the way, as HTTP headers are not enough to express complex data structures,
typia.http.headers()
function has some limitations. If target typeT
is not following those restrictions, compilation errors would be occured.T
must be an object typenull
, butundefined
is possibleboolean
,bigint
,number
,string
or their array types are allowedset-cookie
must be array type