Answer the question
In order to leave comments, you need to log in
Checking the JSON structure coming from the client to Node.JS
There was a task of checking the incoming JSON from the client on node.js. I have implemented a simple function:
json =
key: 'value'
sub:
key: 'value'
extra: 'value'
check = expect json, {key: yes, sub: {key: yes}}
console.log check # true
Answer the question
In order to leave comments, you need to log in
To solve your problem, there is already a ready-made json-gate module .
Used it - works great. Provides many useful features like optional values, list of allowed values and other validators.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question