Skip to content

Conversation

@hudson-ai
Copy link
Contributor

Arguably, this fix could go in derivre, which currently only produces regexes for positive multiples. However, it's easy enough to apply the fix here

Closes #222

@hudson-ai hudson-ai requested a review from riedgar-ms July 30, 2025 16:51

#[rstest]
#[case::positive_multipleof(3)]
#[case::negative_multipleof(-3)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to:
https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.6.2.1
A negative value for multipleOf should be rejected?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also unclear to me if multipleOf should be allowed to be zero, particularly given that JSON doesn't have a concept of NaN.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the draft, it should be strictly greater than zero. Good catch (although it does seem that negative numbers are perfectly well defined, and zero is easy enough to define as "the constant zero")

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

Successfully merging this pull request may close these issues.

[Bug] multipleOf not working with negative numbers

2 participants