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

Accept nullable parameter #472

Open
ronildosouzafb opened this issue Jun 30, 2022 · 3 comments
Open

Accept nullable parameter #472

ronildosouzafb opened this issue Jun 30, 2022 · 3 comments
Labels

Comments

@ronildosouzafb
Copy link

current behavior

schema = {
  "type": "object",
  "properties": {
      "github_url": { "type": "string", "nullable": true }
    }
}

# => The property '#/github_url' of type null did not match the following type: string
JSON::Validator.validate!(schema, { "github_url" => null })

expected behavior

schema = {
  "type": "object",
  "properties": {
      "github_url": { "type": "string", "nullable": true }
    }
}

# => true
JSON::Validator.validate!(schema, { "github_url" => null })

also, without nullable attribute

schema = {
  "type": "object",
  "properties": {
      "github_url": { "type": "string" }
    }
}

# => The property '#/github_url' of type null did not match the following type: string
JSON::Validator.validate!(schema, { "github_url" => null })
@bastelfreak
Copy link
Member

Hi @ronildosouzafb , thanks for raising the issue. Are you able provide a PR for this? On which version of json-schema did you see this?

@ronildosouzafb
Copy link
Author

Hi @bastelfreak, yeah. I will work on open up a PR for this.

@TemaMix
Copy link

TemaMix commented Mar 15, 2023

@ronildosouzafb Hi I run into the same issue :) do you have any ideas on how to fix it?

jahir-husain added a commit to jahir-husain/json-schema that referenced this issue Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants