3 ms·
In theory you could use CUE to validate requests and insert defaults and implied data, replacing Ajv. 1. Get the CUE value representing the schema endpoint 2.
by Kinrany 5y ago
In theory you could use CUE to validate requests and insert defaults and implied data, replacing Ajv.
1. Get the CUE value representing the schema endpoint
2. Convert the JSON request into a CUE value
3. Unify the request with the schema
If unification fails, return 400 Bad Request.
If it succeeds, deserialize the resulting third CUE value into a programming language value.
CUE will fill fields missing from JSON by either using the default values from schema or inferring fields that have only one possible value (which may depend on all the other fields of request and schema).