Giter Site home page Giter Site logo

Comments (4)

coreation avatar coreation commented on July 28, 2024

Noticed this as well, imho the required statement is elementary to perform some schema validation, and currently this is bugged :).

from json-schema.

pietercolpaert avatar pietercolpaert commented on July 28, 2024

Is this bug in every version? Or only in the dev-master?

The code seems to check this:

https://github.com/justinrainbow/json-schema/blob/master/src/JsonSchema/Constraints/Object.php#L70

from json-schema.

mchiocca avatar mchiocca commented on July 28, 2024

The aforementioned code in Constraints/Object.php is checking for the "requires" attribute, not the "required" attribute, which is different.

The value of "required" must be an array containing property names that are required. For example,

{
    "properties": {
        "foo": {"type": "integer"}
    },
    "required": ["foo"]
}

However, the current implementation seems to support "required" only as an attribute on individual properties. For example,

{
    "properties": {
        "foo": {"type": "integer", "required": true}
    }
}

The "requires" attribute is from as early as Draft v0. I'm not that sure that it's supported in Draft v3+. The use of "required" can be done using either the former or the latter example.

from json-schema.

mchiocca avatar mchiocca commented on July 28, 2024

This issue has been fixed by merging #41 into master. Both the draft-03 and 04 specifications for required are now supported.

from json-schema.

Related Issues (20)

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.