Ajv: Validate only returning first error

Created on 15 Oct 2018  路  1Comment  路  Source: ajv-validator/ajv

What version of Ajv are you using? Does the issue happen if you use the latest version?

6.5.4

Ajv options object


JSON Schema

{ 
   "properties": { 
       "email": { "type": "string" },
       "password": { "type": "string" },
        "firstName": { "type": "string" },
        "lastName": { "type": "string" } 
    },
   "required": [ "email", "password", "firstName", "lastName" ],
   "type": "object",
   "definitions": {} 
}

Sample data

{}

Your code

https://runkit.com/myrddraall/5bc4e37afa061f0012b5bf75

const ajv = new Ajv();
ajv.validate(schema, data);
console.log(ajv.errors);

Validation result, data AFTER validation, error messages

[ { keyword: 'required',
    dataPath: '',
    schemaPath: '#/required',
    params: { missingProperty: 'email' },
    message: 'should have required property \'email\'' } ]

What results did you expect?

I would expect an error for each of the required fields rather than only email

Are you going to resolve the issue?

usage

>All comments

That鈥檚 a feature, see options.

Was this page helpful?
0 / 5 - 0 ratings