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

Format attribute should not validate data instances that aren't the instance type to validate #756

Open
DannyvdSluijs opened this issue Oct 4, 2024 · 3 comments · May be fixed by #773
Open
Labels
Bug Good first issue A (simpeler) good first issue for new contributers PRs Welcome

Comments

@DannyvdSluijs
Copy link
Collaborator

DannyvdSluijs commented Oct 4, 2024

Our bowtie report shows that for Draft 3 and Draft 4 has some failing tests with regards to the format attribute.

Some example of these failing test case are:

  • Test: all string formats ignore integers
    • Case: email format
    • Case: ipv4 format
    • Case: ipv6 format

Draft 3 specification

From the spec we can read the following

7.1. Foreword
Structural validation alone may be insufficient to validate that an instance meets all the requirements of an application. The "format" keyword is defined to allow interoperable semantic validation for a fixed subset of values which are accurately described by authoritative resources, be they RFCs or other external specifications.

The value of this keyword is called a format attribute. It MUST be a string. A format attribute can generally only validate a given set of instance types. If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed.

@DannyvdSluijs DannyvdSluijs added PRs Welcome Good first issue A (simpeler) good first issue for new contributers Bug labels Oct 4, 2024
@W0rma
Copy link

W0rma commented Jan 8, 2025

@DannyvdSluijs I will give this a try.

Should this be fixed in 5.x as well or is it sufficient to fix it in master and port it to 6.0.x?

@DannyvdSluijs
Copy link
Collaborator Author

@W0rma that would be great.

Based on the biggest problem for this repo (which is time from contributors, including myself) I would focus the fix on master.

@W0rma
Copy link

W0rma commented Jan 11, 2025

The quote from the issue description seems to be from Draft 4, not from Draft 3.

From Draft-03 section 5.23:

This property defines the type of data, content type, or microformat to be expected in the instance property values. A format attribute MAY be one of the values listed below, and if so, SHOULD adhere to the semantics describing for the format. A format SHOULD only be used to give meaning to primitive types (string, integer, number, or boolean).
Validators MAY (but are not required to) validate that the instance values conform to a format.

I don't read anything similar to If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed. from Draft-04.

However, the bowtie tests suppose that the rule from Draft-04 should apply to Draft-03 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Good first issue A (simpeler) good first issue for new contributers PRs Welcome
Projects
None yet
2 participants