Giter Club home page Giter Club logo

perl-jsv's People

Contributors

ar-tama avatar maedama avatar pmorch avatar tanaka-tatsuya avatar yfuruyama avatar yoshizow avatar zentooo avatar zigorou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

perl-jsv's Issues

Random verification results on enum

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";

Avoid initialization when validating many instances against same schema

I'd expect a way to initialize a schema only once and validate many instances against it, e.g:

my $validator = JSV::Validator->compile($schema);
say $validator->validate($instance) for @instances;

As I read the code, a lot of initialization is done for each instance in JSV::Validator::validate and JSV::Context::validate.

Tests fail (with Data::Walk 2.00)

A number of tests started to fail on my smoker machines. Statistical analysis suggests that the problem is caused by recent Data::Walk versions:

****************************************************************
Regression 'mod:Data::Walk'
****************************************************************
Name                   Theta          StdErr     T-stat
[0='const']           1.0000          0.0000    158397264459701504.00
[1='eq_2.00']        -1.0000          0.0000    -75883399277069552.00

R^2= 1.000, N= 61, K= 2
****************************************************************

json-schema test suite information

Hey Toru. From the looks of your recent work on this module, it looks like you're converting the tests from the json-schema test suite to perl tests. Is this correct? How do I run these tests for your module?

I am working on a module that will allow you to run all of the tests from the test suite without the need to write a new perl test for each one. You define how your module does validation, which draft, and any tests to exclude, and it will run all the tests from the json files.

I'll let you know as soon as it is ready! As I'm doing this as part of my day job, I expect it won't be too far in the future.

No way to extract all error messages separate

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.