Javascript, how to check the all the attributes of an object? Is possible compare it with a schema?

61 views Asked by At

I have an application in Node.js that have a REST service, this service (with POST Method) accept a JSON passed as payload in the body request.

The JSON payload is parsed so I have an Object, at this point I'd like check that all mandatory fields are presents.

I have to check it field by field or there is a way to compare the object to a defined schema?

Which is the best approch?

1

There are 1 answers

0
Daniel On

You can try Joi for schema creation and validating.