#10117·parcel

Support Ranges & Integer Validation In Config Schemas

Author: solonovamaxCreated Mar 20, 2025Updated Sep 13, 2026

feature request

Add support config schemas with ranges & restrictions to only integers for config schemas.

Expected Behavior

The feature would allow specifying optional number properties min and max values for a schema entity of type number for restricting the range, as well as an optional boolean property integer to indicate if it must be an integer (the default, undefined case is the same as false).

Current Behavior

Currently, the config schema only supports declaring a schema with a predefined set of numbers, via the enum property: https://github.com/parcel-bundler/parcel/blob/86bddb4031136f4b1b76e1a9a4c8a53ff4280b42/packages/core/utils/src/schema.js#L47-L51

However, this property is not that useful, as all the possible values must be listed out manually.

Possible Solution

I'm going to open a PR in a few which adds support, because it's not that many lines of change.

Context

An example usecase is the @parcel/transformer-image plugin: https://github.com/parcel-bundler/parcel/blob/86bddb4031136f4b1b76e1a9a4c8a53ff4280b42/packages/transformers/image/src/validateConfig.js#L6-L50

For many of these properties, there are range restrictions on them. However, there are too many values to realistically list all of them. Take quality for example, it must be in the range of 1-100, however listing all integers from 1 to 100 would be rather tedious. So, it would be much better if instead it could be specified as the following:

javascript
properties: {
  quality: {
    type: 'number',
    min: 1,
    max: 100,
    integer: true,
  },
  ...
}

This would restrict it to only integers in the range of 1-100.

Examples