Begin work on purging the range bucket type from the codebase

This commit is contained in:
Oliver-Akins 2025-05-31 23:16:13 -06:00
parent 5fe11fda0d
commit ac93a3342f
3 changed files with 4 additions and 33 deletions

View file

@ -38,7 +38,6 @@ export const api = deepFreeze({
},
schemas: {
buckets: {
range: numberBucketSchema,
number: numberBucketSchema,
string: stringBucketSchema,
},

View file

@ -61,7 +61,7 @@ export function validateBucketConfig(config) {
delete conf.choices;
};
validator.validateConfig(conf);
validator.validateConfig?.(conf);
return conf;
};
@ -74,7 +74,7 @@ const validators = {
opts.trim = true;
opts.blank = false;
},
validateConfig: (config) => {
transformConfig: (config) => {
if (config.choices.length === 0) {
delete config.choices;
config[`-=choices`] = null;
@ -84,35 +84,6 @@ const validators = {
[BucketTypes.NUMBER]: {
field: NumberField,
transformOptions: transformNumberFieldOptions,
validateConfig: (config) => {
if (config.step != null && config.min == null) {
delete config.step;
config[`-=step`] = null;
};
if (
config.min != null
&& config.max != null
&& config.min > config.max
) {
throw new Error(`"min" must be less than "max"`);
}
},
},
[BucketTypes.RANGE]: {
field: NumberField,
transformOptions: transformNumberFieldOptions,
validateConfig: (config) => {
if (config.min == null) {
throw new Error(`"min" must be defined for range buckets`);
};
if (config.max == null) {
throw new Error(`"max" must be defined for range buckets`);
};
if (config.min > config.max) {
throw new Error(`"min" must be less than "max"`);
}
config.step ??= 1;
},
},
};

View file

@ -2,7 +2,7 @@ export function createDiceTable(size) {
return {
name: `Dice/d${size}`,
buckets: {
type: `range`,
type: `number`,
min: 1,
max: size,
step: 1,
@ -10,6 +10,7 @@ export function createDiceTable(size) {
graph: {
type: `bar`,
stacked: true,
showEmptyBuckets: true,
},
};
};