4 ms·
> Also, if you haven't checked it out, typescript-json-schema has some REALLY powerful validation it can do for things like your example (https://youtu.be/HHTDC
by com2kid 4y ago
> Also, if you haven't checked it out, typescript-json-schema has some REALLY powerful validation it can do for things like your example (https://youtu.be/HHTDCY5uh_M?t=1379 https://youtu.be/HHTDCY5uh_M?t=1379). You can do stuff like this
Oh wow I didn't realize TS JSON Schema was capable of all that!
> but there's still nothing _enforcing_ that contract.
Sure there is, the schema on my REST endpoint. Express and AJV check all messages coming in.
It requires changes be non-breaking changes of course, new fields need to be optional, same as protobuf.
Removing a field means making it optional, removing it from all calling code, then removing it from the schema entirely. Real pain, but that is the price you pay if you want required fields. Only really doable if you can also control all the code, but since I'm working on internally facing services only, not an issue. :)