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

Multiple types combined with pattern can break validation #369

Open
jakobsa opened this issue Aug 17, 2022 · 2 comments
Open

Multiple types combined with pattern can break validation #369

jakobsa opened this issue Aug 17, 2022 · 2 comments

Comments

@jakobsa
Copy link
Contributor

jakobsa commented Aug 17, 2022

Given:

{
	type: 'object',
	properties: {
		anyProp: {
			"type": [
                              "string",
                              "boolean"
                          ],
                          "pattern": "^[^${}]+$",
                          "default": true
		}
	}
}

Expected result:

validation ok, and {anyProp: true}

Actual result:

TypeError: e.match is not a function

Analysis:
when applying validation rules, string is expected but other type (in this case: boolean) is given.

@albanm
Copy link
Member

albanm commented Aug 17, 2022

What does json-schema say about that ? Are you sure a validator like ajv will ever accept a boolean value, or will it always estimate that it fails the pattern rule ?

@jakobsa
Copy link
Contributor Author

jakobsa commented Aug 17, 2022

https://www.jsonschemavalidator.net/s/O7JdN2OS is fine with it.

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

2 participants