perl-JSV icon indicating copy to clipboard operation
perl-JSV copied to clipboard

Random verification results on enum

Open maksym3d opened this issue 8 years ago • 0 comments

I seem to get random validation results when validating a valid instance (sometimes the result is '1', sometimes it is '0'). If I remove the 'Palette' attribute - results are always consistent. Further, if I set Palette to invalid value (not present in enum list) - results are also consistently correct (negative). My schema:

{ "title": "My schema", "type": "object", "properties": { "Data": { "type": "object", "properties": { "Label": { "type": "string" }, "Range": { "type": "object", "properties": { "Min": { "type": "number" }, "Max": { "type": "number" } } } } }, "Y Axis": { "type": "object", "properties": { "Label": { "type": "string" }, "Range": { "type": "object", "properties": { "Min": { "type": "number" }, "Max": { "type": "number" } } } } }, "Palette": { "type": "object", "enum": [ { "label": "text1", "legend": "text2" }] } }, "definitions": { "scale": { "type": "string", "enum": ["Linear", "Log"] } } }

My Perl structure to validate: { 'Y Axis' => { 'Range' => { 'Min' => 0.7, 'Max' => 700 }, 'Label' => 'Height (hPa)' }, 'Data' => { 'Label' => 'label 1', 'Range' => { 'Max' => 0.7, 'Min' => 0.5 } }, 'Palette' => { 'label' => "text1", 'legend' => "text2" }

                                      }

Code:

JSV::Validator->load_environments("draft4"); my $validator = JSV::Validator->new(environment => "draft4"); print $validator->validate($schema, $instance) ,"\n";

maksym3d avatar Aug 04 '17 19:08 maksym3d