Skip to content

feat: support minimum / maximum for numbers#140

Merged
mnahkies merged 2 commits into
mainfrom
mn/feat/number-range-validation
Apr 6, 2024
Merged

feat: support minimum / maximum for numbers#140
mnahkies merged 2 commits into
mainfrom
mn/feat/number-range-validation

Conversation

@mnahkies
Copy link
Copy Markdown
Owner

@mnahkies mnahkies commented Apr 6, 2024

  • includes minimum / maximum on the numeric ir model
  • uses these to add validations with zod
  • add prettier to fix bad inline-snapshot indentation (see [Feature]: support biome for jest-snapshot formatting jestjs/jest#15014)
  • memorize openapi validator in unit tests, speeding them up considerably (~6s -> ~1s for the zod spec file)
  • improve test harness for zod to support directly providing IRModel objects, and also execute the resulting schemas to parse a value
    • this makes it easier to write a broader range of tests, and should also prevent misunderstandings of the zod API

Partially addresses #51

mnahkies added 2 commits April 6, 2024 10:41
- includes `minimum` / `maximum` on the numeric ir model
- uses these to add validations with `zod`
- add `prettier` to fix bad inline-snapshot indentation (see
  jestjs/jest#15014)
- memorize openapi validator in unit tests, speeding them up
  considerably (`~6s` -> `~1s` for the zod spec file)
@mnahkies mnahkies merged commit 21f2a76 into main Apr 6, 2024
@mnahkies mnahkies deleted the mn/feat/number-range-validation branch April 6, 2024 09:50
mnahkies added a commit that referenced this pull request Apr 6, 2024
this builds on the speed up from memorizing the validator in #140,
further improving the speed of the zod spec file from `~1s` -> `~200ms`
(a lot better than the original `~6s`!)

there's no longer any need to memorize the validator, since the require
cache effectively does this for us now.

the compiled validation function is pretty large, but committing it
will keep me honest and prove reproducibility thanks to the CI check
for uncommitted changes after running the build / tests.
mnahkies added a commit that referenced this pull request Apr 6, 2024
this builds on the speed up from memorizing the validator in
#140,
further improving the speed of the zod spec file from `~1s` -> `~200ms`
(a lot better than the original `~6s`!) 
(though note, it's a bit of a wash for time in CI given it re-compiles
there)

there's no longer any need to memorize the validator, since the require
cache effectively does this for us now.

the compiled validation function is pretty large, but committing it
will keep me honest and prove reproducibility thanks to the CI check
for uncommitted changes after running the build / tests.
mnahkies added a commit that referenced this pull request Apr 6, 2024
#140 but for `joi` schema builders.

also unifies the test harness between `zod` and `joi` schema builder
tests, hopefully helping me be less lazy about improving the `joi`
schema builder in lockstep with `zod`.
mnahkies added a commit that referenced this pull request Apr 6, 2024
adds support for the rest of the number validation keywords
defined by JSON schema validation.

also fixes a bug in #140 / #143 where `0` would be treated as
`undefined`

ref: https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-6.2
mnahkies added a commit that referenced this pull request Apr 6, 2024
adds support for the rest of the number validation keywords defined by
JSON schema validation.

also fixes a bug in #140 / #143 where `0` would be treated as
`undefined`

relates #51 

ref:
https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-6.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant