diff --git a/module/api.mjs b/module/api.mjs index 0dbaf9d..539e15a 100644 --- a/module/api.mjs +++ b/module/api.mjs @@ -38,7 +38,6 @@ export const api = deepFreeze({ }, schemas: { buckets: { - range: numberBucketSchema, number: numberBucketSchema, string: stringBucketSchema, }, diff --git a/module/utils/buckets.mjs b/module/utils/buckets.mjs index 66a3913..7082df1 100644 --- a/module/utils/buckets.mjs +++ b/module/utils/buckets.mjs @@ -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; - }, }, }; diff --git a/module/utils/databases/utils.mjs b/module/utils/databases/utils.mjs index ba4cf69..58c3907 100644 --- a/module/utils/databases/utils.mjs +++ b/module/utils/databases/utils.mjs @@ -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, }, }; };