Enhancement: Support metadata validation for numeric types
See original GitHub issueIs your feature request related to a problem? Please describe.
I’ve been working to define the metadata keys for a theme I’m developing in Front Matter. Today, I was defining the settings for general content pages based on the work I’ve done to develop JSON schemas for site configuration and metadata.
While updating the content type definition in Front Matter for the Platen.TableOfContents.MinimumLevel
and Platen.TableOfContents.MaximumLevel
fields, I realized that while I can require the values be numbers, I can’t require that they be within a specific range. In this case, I would like to set the minimum as 1
and maximum as 6
.
Describe the solution you’d like
I’d like additional keys for defining fields with a type
of number
:
minimum
: The minimum value the number can be, inclusive. For a value of3
:2
is invalid3
is valid4
is valid
maximum
: The maximum value the number can be, inclusive. For a value of3
:2
is valid3
is valid4
is invalid
exlusiveMinimum
: The minimum value the number can be, exclusive. For a value of3
:2
is invalid3
is invalid4
is valid
exclusiveMaximum
: The maximum value the number can be, exclusive. For a value of3
:2
is invalid3
is valid4
is valid
Describe alternatives you’ve considered
I’m not sure I see another way to handle metadata validation without transitioning towards a semi-unified model between metadata definitions and data-type definitions, which can take advantage of JSON Schema functionality but are more complex to write.
Additional context
Similar to the newly implemented when
functionality, I think there’s a lot of utility in being able to define a validation
field that allows a configuration author to opt-in for more complex configuration definition to provide a better UX for end users.
For example, even with the described additional keys above, there’s no way to also validate that the specified value for the MinimumLevel
field on a page is less than or equal to the MaximumLevel
field’s value.
Issue Analytics
- State:
- Created 10 months ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
@michaeltlombardi it might have been me. Think I confused it with the conditional UI functionality and its operators 🫣
@dennisl68-castra first, there is a need for a simple way to validate metadata/fields to define when they are allowed to appear and when not. Once that is implemented, we can start thinking about custom scripts.
@michaeltlombardi, these extra operators make sense.