Validate with Ajv
import Ajv from 'ajv';
const ajv = new Ajv({ allErrors: true, strict: true });
const validate = ajv.compile({ type: 'object', properties: { id: { type: 'string' } }, required: ['id'], additionalProperties: false });
console.log(validate({ id: 'abc' })); // true
console.log(validate({})); // false, see validate.errors