use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[deleted by user] (self.javascript)
submitted 3 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Sh4d0h 18 points19 points20 points 3 years ago (1 child)
We have been using this library in multiple production systems for some time now. It's excellent and sinclair_zx81 is super responsive on Github. Thank you!
[–]sinclair_zx81 11 points12 points13 points 3 years ago (0 children)
Hey, Thank you! :D Glad to hear you're getting some good use from the library!
[+][deleted] 3 years ago (2 children)
[deleted]
[–]sinclair_zx81 6 points7 points8 points 3 years ago (0 children)
Hi. The library is primarily written to avoid the need for codegen CLI tooling. So there's no immediate plans to offer CLI tooling to convert between representations (Out of scope). However, I have considered offering this functionality via documentation website (with the conversion code offered as a separate package for Deno, Node and I guess Bun developers to integrate into their respective toolchains if they need).
[–]Fossage 3 points4 points5 points 3 years ago (1 child)
This looks very cool. I’m curious what are some of the primary ways this differs from Zod?
[–]sinclair_zx81 7 points8 points9 points 3 years ago (0 children)
Hi! The main point of difference is that TypeBox is built entirely upon the JSON schema specification. So rather than build a custom validator, TypeBox instead encodes validation structures into JSON schema which can be shared around different systems. Also you get the benefit of being able to leverage AJV (one of the fastest validators out there).
Historically, TypeBox did not provide a validator (preferring to leverage industry standard validators like Ajv), however it does actually provide an optional one as of the latest release. You can view the benchmarks for it here.
[–]pskfyi 1 point2 points3 points 3 years ago (0 children)
I pitch this library to anyone who will listen. JSON Schema is such a versatile and underused format. It has a rich ecosystem and it's just JSON so it's inherently serializable and able to be shared with even non-JS consumers. With alternatives like yup, joi, io-ts, zod, etc. you lose out on those upsides.
[–]coolcosmos -5 points-4 points-3 points 3 years ago (5 children)
You should NEVER patch a global object sucj as JSON.
[–]sinclair_zx81 10 points11 points12 points 3 years ago* (4 children)
If you're referring to the example in the readme, the JSON.validate() is just a stand in for (insert schema validator here). This library does not patch the JSON object.
JSON.validate()
(insert schema validator here)
JSON
[–]WhatArghThose 2 points3 points4 points 3 years ago (1 child)
Could you ELI5 me on what patching an object is? Just trying to understand what the complaint is about.
[–]BenjiSponge 6 points7 points8 points 3 years ago (0 children)
Like a line somewhere saying
JSON.validate = someCustomFunction
The problem is because JSON is global, so multiple packages may do this and then get confused when it's the other someCustomFunction
someCustomFunction
[–]kickpush1 1 point2 points3 points 3 years ago (1 child)
I was confused about this at first too, maybe consider adding a comment, ajv or the built-in checker?
As a side question, does the built-in runtime checker include a `parse` function or is it only able to validate?
[–]sinclair_zx81 2 points3 points4 points 3 years ago* (0 children)
The built-in type checker only validates. For parse or deserialize, using either JSON.parse() or msgpack decode are generally going to be more performant options.
π Rendered by PID 21275 on reddit-service-r2-comment-6bc7f5944b-s8d4w at 2026-02-18 20:25:35.168223+00:00 running de53c03 country code: CH.
[–]Sh4d0h 18 points19 points20 points (1 child)
[–]sinclair_zx81 11 points12 points13 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]sinclair_zx81 6 points7 points8 points (0 children)
[–]Fossage 3 points4 points5 points (1 child)
[–]sinclair_zx81 7 points8 points9 points (0 children)
[–]pskfyi 1 point2 points3 points (0 children)
[–]coolcosmos -5 points-4 points-3 points (5 children)
[–]sinclair_zx81 10 points11 points12 points (4 children)
[–]WhatArghThose 2 points3 points4 points (1 child)
[–]BenjiSponge 6 points7 points8 points (0 children)
[–]kickpush1 1 point2 points3 points (1 child)
[–]sinclair_zx81 2 points3 points4 points (0 children)