Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type casting results in PHP error exception when object type is given #561

Closed
OneEyedSpaceFish opened this issue Jan 25, 2019 · 2 comments
Closed

Comments

@OneEyedSpaceFish
Copy link

Array validation for a given type, in this example integer fails with PHP internal error exception being thrown if a client supplies an array with an object element in it.

This seems to be the case for string type as well, so I'd assume that this is a more common issue across all types of constraints.

JSON body: [{}]

Integer example:
Schema

    "type": "array",
    "minItems": 1,
    "required": true,
    "uniqueItems": true,
    "additionalProperties": false,
    "items": {
        "type": "integer",
        "minimum": 1
    }

String Exception
PhpErrorException Exception; Code: internalError; Message: mb_detect_encoding() expects parameter 1 to be string, object given; File: .../justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.php; Line: 54;

Integer Exception
PhpErrorException Exception; Code: internalError; Message: Object of class stdClass could not be converted to int; File: .../justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.php; Line: 38;

Versions affected: v5.2.8, v5.2.7, v5.2.6 (possibly more)

@OneEyedSpaceFish OneEyedSpaceFish changed the title Type casting results in internal error exception when object type is given Type casting results in PHP error exception when object type is given Jan 25, 2019
@shmax
Copy link
Collaborator

shmax commented Jan 25, 2019

Feel free to open a PR

@DannyvdSluijs
Copy link
Collaborator

@OneEyedSpaceFish in an attempt to cleanup this repo we are trying to filter the issues and see which ones might be closed. Is it still something worth pursuing, could you provide with a bit more detailed reproduction steps perhaps? Or is this is a rather old issue, which sadly was left unanswered, and can be closed? Feel free to close it yourself with some comments if helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants