jjv icon indicating copy to clipboard operation
jjv copied to clipboard

oneOf or string format validators issue

Open avaly opened this issue 9 years ago • 0 comments

There seems to be an issue in either the oneOf logic or the format validators. The following test fixture returns the errors below when unit tests as ran:

[
    {
        "description": "oneOf bug",
        "schema": {
            "oneOf": [
                {
                    "type": "string",
                    "format": "email"
                },
                {
                    "type": "string",
                    "format": "uri"
                }
            ]
        },
        "tests": [
            {
                "description": "first oneOf valid",
                "data": "[email protected]",
                "valid": true
            },
            {
                "description": "second oneOf valid",
                "data": "http://google.com",
                "valid": true
            },
            {
                "description": "neither oneOf valid format",
                "data": "asd",
                "valid": false
            },
            {
                "description": "neither oneOf valid type",
                "data": 1,
                "valid": false
            }
        ]
    }
]
  _bug.json
    oneOf bug
      1) first oneOf valid


  0 passing (7ms)
  1 failing

  1) _bug.json oneOf bug first oneOf valid:
     AssertionError: expected { validation: { oneOf: true } } to equal null

Tested with version 1.0.2.

avaly avatar Feb 17 '15 07:02 avaly