goodeggs / unionized

A factory library for setting up JavaScript objects as test data.
MIT License
13 stars 3 forks source link

fix(JSONSchemaFactory): respect underlying number range for "decimal" #131

Closed serhalp closed 3 years ago

serhalp commented 3 years ago

In https://github.com/goodeggs/unionized/pull/130 I implemented support for a new "decimal" string format in JSONSchemaFactory. However, this isn't respecting the number properties like minimum, maximum, exclusiveMinimum, and exclusiveMaximum. This was kind of the whole point and it isn't viable for our use cases without it, since it otherwise generates data that doesn't validate against its own schema.

This fixes the issue by reusing the number data generation logic and then just calling toString() on the result. Simple!