Repository navigation
Replies: 1 comment 1 reply
|
For runtime schema inspection, keeping an explicit marker is a reasonable approach here. The codec stores the encoded schema plus If you need the TypeScript type instead, TypeBox provides For a runtime walker, your marker can stay next to the codec definition. Treat that metadata as your application's contract rather than evidence inferred from the callback. Calling the decoder with a sample value would only tell you the result for that sample, and might execute arbitrary application code. Tested with TypeBox 1.4.2 and TypeScript 5.9.3 ( const IsDateTime = (schema: t.TSchema) =>
'@type' in schema &&
schema['@type'] === 'http://www.w3.org/2001/XMLSchema#dateTime';I checked that the marker survives codec construction, |
Uh oh!
There was an error while loading. Please reload this page.
for same case, if we want to declare a
Dateproperty, but this property isstringin http request, so we can doFor
createdAt, the input type isstring, the output type isDate.I can use
to determine it is
Codec,OptionalandString, but can determine the output type. I add a "@type" property to mark it.Do we have a better plan to do this?
All reactions