zigorou / perl-JSV

JSON Schema implementation for Perl
Other
25 stars 17 forks source link

No way to extract all error messages separate #44

Open nicolasfranck opened 8 years ago

nicolasfranck commented 8 years ago

The error messages seem to be grouped into similar groups. E.g. all missing "required" properties. But the JSV::Result does not have a method to extract the properties in question.

schema:

  'required' => [ 'firstName', 'lastName' ],
  'properties' => {
    'firstName' => { 'type' => 'string' },
    'lastName' => { 'type' => 'string' },
    'age' => { 
      'type' => 'integer', 
      'description' => 'Age in years',                                                         
      'minimum' => 0
    }
  },
  'type' => 'object'

object:

  { }

JSV::Result:

  bless( {
                 'errors' => [
                               {
                                 'schema' => {
                                               'required' => [
                                                               'firstName',
                                                               'lastName'
                                                             ],
                                               'properties' => {
                                                                 'firstName' => {
                                                                                  'type' => 'string'
                                                                                },
                                                                 'lastName' => {
                                                                                 'type' => 'string'
                                                                               },
                                                                 'age' => {
                                                                            'type' => 'integer',
                                                                            'description' => 'Age in years',
                                                                            'minimum' => 0
                                                                          }
                                                               },
                                               'type' => 'object'
                                             },
                                 'schema_pointer' => '',
                                 'pointer' => '',
                                 'keyword' => 'required',
                                 'message' => 'The instance properties has not required properties (missing: firstName, lastName)',
                                 'instance' => {},
                                 'schema_pointer_history' => []
                               }
                             ],
                 'error' => ''
               }, 'JSV::Result' );

The properties "lastName" and "firstName" should be stored somewhere in this result.