New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeBox 0.25.0 #271
Merged
Merged
TypeBox 0.25.0 #271
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds
Type.Date()
to TypeBox and formalizes Extended Type representations. This PR constitutes a minor semver release.Type.Date()
The new Date type will validate via
instanceof Date
without constraints but provides 4 range constraint options tied to thetimestamp
as given bydate.getTime()
. Becausetimestamp
is numeric, TypeBox uses similar constraints toTNumber
andTInteger
.The following constraints are supported.
Note: TypeBox does not factor timezone information encoded in the date, and will only validate based on
UTC+0
offsets from the Unix Epoch on January 1st 1970 which is the UTC offset given bydate.getTime()
. As.getTime()
is uniform across timezones, users should configure constraints to match constraint ranges relative toUTC+0
.Documentation
The documention for
Type.Date()
has been added to theExtended
type section as it will require configuration before use in Ajv. Due to the configuration requirement and the high likelihood of this type being used in non-configured environments, additional documentation for configuring bothType.Date()
andType.Uint8Array()
have been included in the project readme.In addition, the prefixed
Standard
andExtended
JSDoc comments make a return for intellisense enabled editors (such as vscode). This to make more clear which types can be used safely without configuration and which cannot.Extended Schema Representation
This PR also updates the schema representations for Extended types. These updates are inline with adding
Type.Date()
as well as making provisions for potential future types (such aType.Temporal()
). The representations now include the additional properties ofinstanceOf
andtypeOf
(which are used as configurable hooks for Ajv and other validators). Due to the change in representations for these types, this will require a minor semver revision.From
0.25.0
onwards, the recommendation for custom schemas created withType.Unsafe()
will be to adopt the conventions used for the TypeBox extended typesType.Date()
andType.Undefined()
. This with the intent to provide concise and extensible configuration setup for TypeBox + Ajv.