@gravity-ui/dynamic-forms 5.17.1 → 5.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/lib/kit/components/Inputs/ColorPicker/ColorPicker.js +7 -0
- package/build/cjs/lib/kit/components/Inputs/TextContent/TextContent.js +2 -2
- package/build/cjs/lib/unstable/core/Entity/Entity.js +78 -0
- package/build/cjs/lib/unstable/core/Entity/index.js +5 -0
- package/build/cjs/lib/unstable/core/Entity/types.js +2 -0
- package/build/cjs/lib/unstable/core/Entity/utils.js +40 -0
- package/build/cjs/lib/unstable/core/SchemaRenderer/SchemaRenderer.js +12 -0
- package/build/cjs/lib/unstable/core/SchemaRenderer/index.js +5 -0
- package/build/cjs/lib/unstable/core/constants.js +28 -0
- package/build/cjs/lib/unstable/core/index.js +15 -0
- package/build/cjs/lib/unstable/core/types/components.js +2 -0
- package/build/cjs/lib/unstable/core/types/config.js +2 -0
- package/build/cjs/lib/unstable/core/types/helpers.js +2 -0
- package/build/cjs/lib/unstable/core/types/index.js +8 -0
- package/build/cjs/lib/unstable/core/types/schema.js +2 -0
- package/build/cjs/lib/unstable/core/types/validation.js +2 -0
- package/build/cjs/lib/unstable/core/types/values.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/constants.js +4 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/hooks/index.js +7 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/hooks/useEntitiesState.js +25 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/hooks/useSchemaRendererMutators.js +17 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/index.js +10 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/async-validation/async-validation.js +35 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/async-validation/index.js +5 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/async-validation/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/external-errors/external-errors.js +60 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/external-errors/index.js +5 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/external-errors/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/index.js +16 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/index.js +5 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/schema-mutators.js +81 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/index.js +5 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/trigger-fields.js +12 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.js +86 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/common.js +11 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/get-ajv-validate.js +39 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/get-validate.js +67 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/index.js +7 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/process-ajv-error.js +51 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/process-ajv-validate-errors.js +43 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/process-entity-parameters-error.js +36 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/process-errors-state.js +17 -0
- package/build/cjs/lib/unstable/core/utils/common.js +180 -0
- package/build/cjs/lib/unstable/core/utils/index.js +4 -0
- package/build/cjs/lib/unstable/kit/Accordeon.js +31 -0
- package/build/cjs/lib/unstable/kit/Any.js +21 -0
- package/build/cjs/lib/unstable/kit/ArrayBase.css +23 -0
- package/build/cjs/lib/unstable/kit/ArrayBase.js +101 -0
- package/build/cjs/lib/unstable/kit/MultiSelect.css +6 -0
- package/build/cjs/lib/unstable/kit/MultiSelect.js +66 -0
- package/build/cjs/lib/unstable/kit/ObjectBase.css +10 -0
- package/build/cjs/lib/unstable/kit/ObjectBase.js +71 -0
- package/build/cjs/lib/unstable/kit/Row.css +73 -0
- package/build/cjs/lib/unstable/kit/Row.js +50 -0
- package/build/cjs/lib/unstable/kit/Text.js +259 -0
- package/build/cjs/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.js +29 -0
- package/build/cjs/lib/unstable/kit/components/ArrayRemoveButton/index.js +5 -0
- package/build/cjs/lib/unstable/kit/components/ControlError/ControlError.css +33 -0
- package/build/cjs/lib/unstable/kit/components/ControlError/ControlError.js +15 -0
- package/build/cjs/lib/unstable/kit/components/ControlError/index.js +5 -0
- package/build/cjs/lib/unstable/kit/components/HTMLContent/HTMLContent.js +11 -0
- package/build/cjs/lib/unstable/kit/components/HTMLContent/index.js +5 -0
- package/build/cjs/lib/unstable/kit/components/index.js +9 -0
- package/build/cjs/lib/unstable/kit/config.js +68 -0
- package/build/cjs/lib/unstable/kit/constants/config.js +62 -0
- package/build/cjs/lib/unstable/kit/constants/index.js +6 -0
- package/build/cjs/lib/unstable/kit/controls/ArrayBase/ArrayBase.js +46 -0
- package/build/cjs/lib/unstable/kit/controls/ArrayBase/index.js +4 -0
- package/build/cjs/lib/unstable/kit/controls/Checkbox/Checkbox.css +5 -0
- package/build/cjs/lib/unstable/kit/controls/Checkbox/Checkbox.js +16 -0
- package/build/cjs/lib/unstable/kit/controls/Checkbox/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.js +37 -0
- package/build/cjs/lib/unstable/kit/controls/CheckboxGroup/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/ColorPicker/ColorPicker.js +24 -0
- package/build/cjs/lib/unstable/kit/controls/ColorPicker/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/DateInput/DateInput.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/DateInput/DateInput.js +55 -0
- package/build/cjs/lib/unstable/kit/controls/DateInput/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/MultiSelect/MultiSelect.js +35 -0
- package/build/cjs/lib/unstable/kit/controls/MultiSelect/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/NumberBase/Number.js +12 -0
- package/build/cjs/lib/unstable/kit/controls/NumberBase/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/ObjectBase/ObjectBase.js +33 -0
- package/build/cjs/lib/unstable/kit/controls/ObjectBase/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/Password/Password.js +12 -0
- package/build/cjs/lib/unstable/kit/controls/Password/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/RadioGroup/RadioGroup.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/RadioGroup/RadioGroup.js +24 -0
- package/build/cjs/lib/unstable/kit/controls/RadioGroup/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/RangeSlider/RangeSlider.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/RangeSlider/RangeSlider.js +33 -0
- package/build/cjs/lib/unstable/kit/controls/RangeSlider/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/Select/Select.js +32 -0
- package/build/cjs/lib/unstable/kit/controls/Select/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/Slider/Slider.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/Slider/Slider.js +19 -0
- package/build/cjs/lib/unstable/kit/controls/Slider/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/StringBase/StringBase.js +12 -0
- package/build/cjs/lib/unstable/kit/controls/StringBase/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/Switch/Switch.css +5 -0
- package/build/cjs/lib/unstable/kit/controls/Switch/Switch.js +16 -0
- package/build/cjs/lib/unstable/kit/controls/Switch/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/TextArea/TextArea.js +12 -0
- package/build/cjs/lib/unstable/kit/controls/TextArea/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/index.js +35 -0
- package/build/cjs/lib/unstable/kit/styles/functions.css +0 -0
- package/build/cjs/lib/unstable/kit/styles/variables.css +0 -0
- package/build/cjs/lib/unstable/kit/utils/cn.js +6 -0
- package/build/cjs/lib/unstable/kit/utils/common.js +27 -0
- package/build/cjs/lib/unstable/kit/utils/index.js +11 -0
- package/build/cjs/lib/unstable/kit/wrappers/Row/Row.css +27 -0
- package/build/cjs/lib/unstable/kit/wrappers/Row/Row.js +34 -0
- package/build/cjs/lib/unstable/kit/wrappers/Row/index.js +5 -0
- package/build/cjs/lib/unstable/kit/wrappers/Transparent/Transparent.css +6 -0
- package/build/cjs/lib/unstable/kit/wrappers/Transparent/Transparent.js +15 -0
- package/build/cjs/lib/unstable/kit/wrappers/Transparent/index.js +5 -0
- package/build/cjs/lib/unstable/kit/wrappers/index.js +7 -0
- package/build/cjs/unstable.js +10 -0
- package/build/esm/lib/kit/components/Inputs/ColorPicker/ColorPicker.d.ts +15 -0
- package/build/esm/lib/kit/components/Inputs/ColorPicker/ColorPicker.js +7 -0
- package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.js +1 -1
- package/build/esm/lib/unstable/core/Entity/Entity.d.ts +10 -0
- package/build/esm/lib/unstable/core/Entity/Entity.js +74 -0
- package/build/esm/lib/unstable/core/Entity/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/Entity/index.js +1 -0
- package/build/esm/lib/unstable/core/Entity/types.d.ts +27 -0
- package/build/esm/lib/unstable/core/Entity/types.js +1 -0
- package/build/esm/lib/unstable/core/Entity/utils.d.ts +3 -0
- package/build/esm/lib/unstable/core/Entity/utils.js +35 -0
- package/build/esm/lib/unstable/core/SchemaRenderer/SchemaRenderer.d.ts +5 -0
- package/build/esm/lib/unstable/core/SchemaRenderer/SchemaRenderer.js +8 -0
- package/build/esm/lib/unstable/core/SchemaRenderer/index.d.ts +1 -0
- package/build/esm/lib/unstable/core/SchemaRenderer/index.js +1 -0
- package/build/esm/lib/unstable/core/constants.d.ts +22 -0
- package/build/esm/lib/unstable/core/constants.js +25 -0
- package/build/esm/lib/unstable/core/index.d.ts +5 -0
- package/build/esm/lib/unstable/core/index.js +4 -0
- package/build/esm/lib/unstable/core/types/components.d.ts +29 -0
- package/build/esm/lib/unstable/core/types/components.js +1 -0
- package/build/esm/lib/unstable/core/types/config.d.ts +36 -0
- package/build/esm/lib/unstable/core/types/config.js +1 -0
- package/build/esm/lib/unstable/core/types/helpers.d.ts +18 -0
- package/build/esm/lib/unstable/core/types/helpers.js +1 -0
- package/build/esm/lib/unstable/core/types/index.d.ts +5 -0
- package/build/esm/lib/unstable/core/types/index.js +5 -0
- package/build/esm/lib/unstable/core/types/schema.d.ts +1186 -0
- package/build/esm/lib/unstable/core/types/schema.js +1 -0
- package/build/esm/lib/unstable/core/types/validation.d.ts +39 -0
- package/build/esm/lib/unstable/core/types/validation.js +1 -0
- package/build/esm/lib/unstable/core/types/values.d.ts +4 -0
- package/build/esm/lib/unstable/core/types/values.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/constants.d.ts +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/constants.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/useEntitiesState.d.ts +7 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/useEntitiesState.js +20 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/useSchemaRendererMutators.d.ts +10 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/useSchemaRendererMutators.js +13 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/index.d.ts +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/index.js +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/async-validation.d.ts +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/async-validation.js +29 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/types.d.ts +34 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/external-errors.d.ts +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/external-errors.js +54 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/types.d.ts +25 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/index.d.ts +13 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/index.js +13 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/schema-mutators.d.ts +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/schema-mutators.js +75 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/types.d.ts +26 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/trigger-fields.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/trigger-fields.js +8 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/types.d.ts +6 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/types.d.ts +22 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.d.ts +37 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.js +81 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/common.d.ts +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/common.js +7 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/get-ajv-validate.d.ts +11 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/get-ajv-validate.js +34 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/get-validate.d.ts +14 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/get-validate.js +62 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-ajv-error.d.ts +10 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-ajv-error.js +46 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-ajv-validate-errors.d.ts +20 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-ajv-validate-errors.js +39 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-entity-parameters-error.d.ts +15 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-entity-parameters-error.js +31 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-errors-state.d.ts +12 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-errors-state.js +12 -0
- package/build/esm/lib/unstable/core/utils/common.d.ts +49 -0
- package/build/esm/lib/unstable/core/utils/common.js +165 -0
- package/build/esm/lib/unstable/core/utils/index.d.ts +1 -0
- package/build/esm/lib/unstable/core/utils/index.js +1 -0
- package/build/esm/lib/unstable/kit/Accordeon.d.ts +3 -0
- package/build/esm/lib/unstable/kit/Accordeon.js +26 -0
- package/build/esm/lib/unstable/kit/Any.d.ts +2 -0
- package/build/esm/lib/unstable/kit/Any.js +16 -0
- package/build/esm/lib/unstable/kit/ArrayBase.css +23 -0
- package/build/esm/lib/unstable/kit/ArrayBase.d.ts +3 -0
- package/build/esm/lib/unstable/kit/ArrayBase.js +97 -0
- package/build/esm/lib/unstable/kit/MultiSelect.css +6 -0
- package/build/esm/lib/unstable/kit/MultiSelect.d.ts +7 -0
- package/build/esm/lib/unstable/kit/MultiSelect.js +62 -0
- package/build/esm/lib/unstable/kit/ObjectBase.css +10 -0
- package/build/esm/lib/unstable/kit/ObjectBase.d.ts +8 -0
- package/build/esm/lib/unstable/kit/ObjectBase.js +66 -0
- package/build/esm/lib/unstable/kit/Row.css +73 -0
- package/build/esm/lib/unstable/kit/Row.d.ts +11 -0
- package/build/esm/lib/unstable/kit/Row.js +47 -0
- package/build/esm/lib/unstable/kit/Text.d.ts +6 -0
- package/build/esm/lib/unstable/kit/Text.js +255 -0
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.d.ts +5 -0
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.js +24 -0
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/index.js +1 -0
- package/build/esm/lib/unstable/kit/components/ControlError/ControlError.css +33 -0
- package/build/esm/lib/unstable/kit/components/ControlError/ControlError.d.ts +9 -0
- package/build/esm/lib/unstable/kit/components/ControlError/ControlError.js +11 -0
- package/build/esm/lib/unstable/kit/components/ControlError/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/ControlError/index.js +1 -0
- package/build/esm/lib/unstable/kit/components/HTMLContent/HTMLContent.d.ts +6 -0
- package/build/esm/lib/unstable/kit/components/HTMLContent/HTMLContent.js +7 -0
- package/build/esm/lib/unstable/kit/components/HTMLContent/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/HTMLContent/index.js +1 -0
- package/build/esm/lib/unstable/kit/components/index.d.ts +3 -0
- package/build/esm/lib/unstable/kit/components/index.js +3 -0
- package/build/esm/lib/unstable/kit/config.d.ts +95 -0
- package/build/esm/lib/unstable/kit/config.js +65 -0
- package/build/esm/lib/unstable/kit/constants/config.d.ts +112 -0
- package/build/esm/lib/unstable/kit/constants/config.js +59 -0
- package/build/esm/lib/unstable/kit/constants/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/constants/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/ArrayBase/ArrayBase.d.ts +8 -0
- package/build/esm/lib/unstable/kit/controls/ArrayBase/ArrayBase.js +42 -0
- package/build/esm/lib/unstable/kit/controls/ArrayBase/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/ArrayBase/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/Checkbox.css +5 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/Checkbox.d.ts +7 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/Checkbox.js +13 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.css +3 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.d.ts +10 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.js +34 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/ColorPicker/ColorPicker.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/ColorPicker/ColorPicker.js +21 -0
- package/build/esm/lib/unstable/kit/controls/ColorPicker/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/ColorPicker/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/DateInput.css +3 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/DateInput.d.ts +9 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/DateInput.js +53 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/MultiSelect/MultiSelect.d.ts +8 -0
- package/build/esm/lib/unstable/kit/controls/MultiSelect/MultiSelect.js +32 -0
- package/build/esm/lib/unstable/kit/controls/MultiSelect/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/MultiSelect/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/NumberBase/Number.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/NumberBase/Number.js +8 -0
- package/build/esm/lib/unstable/kit/controls/NumberBase/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/NumberBase/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/ObjectBase/ObjectBase.d.ts +8 -0
- package/build/esm/lib/unstable/kit/controls/ObjectBase/ObjectBase.js +29 -0
- package/build/esm/lib/unstable/kit/controls/ObjectBase/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/ObjectBase/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Password/Password.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/Password/Password.js +8 -0
- package/build/esm/lib/unstable/kit/controls/Password/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Password/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/RadioGroup.css +3 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/RadioGroup.d.ts +9 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/RadioGroup.js +22 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/RangeSlider.css +3 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/RangeSlider.d.ts +8 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/RangeSlider.js +31 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Select/Select.d.ts +9 -0
- package/build/esm/lib/unstable/kit/controls/Select/Select.js +29 -0
- package/build/esm/lib/unstable/kit/controls/Select/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Select/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Slider/Slider.css +3 -0
- package/build/esm/lib/unstable/kit/controls/Slider/Slider.d.ts +7 -0
- package/build/esm/lib/unstable/kit/controls/Slider/Slider.js +16 -0
- package/build/esm/lib/unstable/kit/controls/Slider/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Slider/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/StringBase/StringBase.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/StringBase/StringBase.js +8 -0
- package/build/esm/lib/unstable/kit/controls/StringBase/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/StringBase/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Switch/Switch.css +5 -0
- package/build/esm/lib/unstable/kit/controls/Switch/Switch.d.ts +7 -0
- package/build/esm/lib/unstable/kit/controls/Switch/Switch.js +13 -0
- package/build/esm/lib/unstable/kit/controls/Switch/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Switch/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/TextArea/TextArea.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/TextArea/TextArea.js +8 -0
- package/build/esm/lib/unstable/kit/controls/TextArea/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/TextArea/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/index.d.ts +16 -0
- package/build/esm/lib/unstable/kit/controls/index.js +16 -0
- package/build/esm/lib/unstable/kit/styles/functions.css +0 -0
- package/build/esm/lib/unstable/kit/styles/variables.css +0 -0
- package/build/esm/lib/unstable/kit/utils/cn.d.ts +1 -0
- package/build/esm/lib/unstable/kit/utils/cn.js +3 -0
- package/build/esm/lib/unstable/kit/utils/common.d.ts +7 -0
- package/build/esm/lib/unstable/kit/utils/common.js +19 -0
- package/build/esm/lib/unstable/kit/utils/index.d.ts +2 -0
- package/build/esm/lib/unstable/kit/utils/index.js +2 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/Row.css +27 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/Row.d.ts +7 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/Row.js +31 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/index.js +1 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/Transparent.css +6 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/Transparent.d.ts +4 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/Transparent.js +12 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/index.js +1 -0
- package/build/esm/lib/unstable/kit/wrappers/index.d.ts +2 -0
- package/build/esm/lib/unstable/kit/wrappers/index.js +2 -0
- package/build/esm/unstable.d.ts +4 -0
- package/build/esm/unstable.js +4 -0
- package/package.json +24 -2
|
@@ -0,0 +1,1186 @@
|
|
|
1
|
+
import type { EntityType, JsonSchemaType } from '../constants';
|
|
2
|
+
import type { SchemaRendererConfig } from './config';
|
|
3
|
+
import type { ExtractControlProps, ExtractViewProps, ExtractWrapperProps, ObjectKeys } from './helpers';
|
|
4
|
+
import type { ErrorMessages } from './validation';
|
|
5
|
+
import type { ArrayValue, FieldValue, ObjectValue } from './values';
|
|
6
|
+
type ControlEntityParameters<TypeConfig extends SchemaRendererConfig[EntityType], Control extends ObjectKeys<TypeConfig['controls']> = ObjectKeys<TypeConfig['controls']>> = [Control] extends [never] ? {} : {
|
|
7
|
+
[C in Control]: {
|
|
8
|
+
/**
|
|
9
|
+
* Identifier of a control registered in `config[entityType].controls`. Selects
|
|
10
|
+
* which React component renders the field in form mode. When omitted, the
|
|
11
|
+
* renderer falls back to the default control for this entity type.
|
|
12
|
+
*/
|
|
13
|
+
controlType?: C;
|
|
14
|
+
/**
|
|
15
|
+
* Extra props forwarded to the selected control. Typed to the `controlProps`
|
|
16
|
+
* shape declared by the chosen control component.
|
|
17
|
+
*/
|
|
18
|
+
controlProps?: ExtractControlProps<TypeConfig['controls'][C]>;
|
|
19
|
+
};
|
|
20
|
+
}[Control];
|
|
21
|
+
type ControlWrapperEntityParameters<TypeConfig extends SchemaRendererConfig[EntityType], Wrapper extends ObjectKeys<TypeConfig['wrappers']> = ObjectKeys<TypeConfig['wrappers']>> = [Wrapper] extends [never] ? {} : {
|
|
22
|
+
[W in Wrapper]: {
|
|
23
|
+
/**
|
|
24
|
+
* Identifier of a wrapper registered in `config[entityType].wrappers`. The
|
|
25
|
+
* wrapper component is rendered around the control in form mode (e.g. to add
|
|
26
|
+
* a label, layout, or visibility logic).
|
|
27
|
+
*/
|
|
28
|
+
controlWrapperType?: W;
|
|
29
|
+
/**
|
|
30
|
+
* Extra props forwarded to the selected control wrapper. Typed to the
|
|
31
|
+
* `wrapperProps` shape declared by the chosen wrapper component.
|
|
32
|
+
*/
|
|
33
|
+
controlWrapperProps?: ExtractWrapperProps<TypeConfig['wrappers'][W]>;
|
|
34
|
+
};
|
|
35
|
+
}[Wrapper];
|
|
36
|
+
type ViewEntityParameters<TypeConfig extends SchemaRendererConfig[EntityType], View extends ObjectKeys<TypeConfig['views']> = ObjectKeys<TypeConfig['views']>> = [View] extends [never] ? {} : {
|
|
37
|
+
[V in View]: {
|
|
38
|
+
/**
|
|
39
|
+
* Identifier of a view registered in `config[entityType].views`. Selects which
|
|
40
|
+
* React component renders the field in overview (read-only) mode. When omitted,
|
|
41
|
+
* the renderer falls back to the default view for this entity type.
|
|
42
|
+
*/
|
|
43
|
+
viewType?: V;
|
|
44
|
+
/**
|
|
45
|
+
* Extra props forwarded to the selected view. Typed to the `viewProps` shape
|
|
46
|
+
* declared by the chosen view component.
|
|
47
|
+
*/
|
|
48
|
+
viewProps?: ExtractViewProps<TypeConfig['views'][V]>;
|
|
49
|
+
};
|
|
50
|
+
}[View];
|
|
51
|
+
type ViewWrapperEntityParameters<TypeConfig extends SchemaRendererConfig[EntityType], Wrapper extends ObjectKeys<TypeConfig['wrappers']> = ObjectKeys<TypeConfig['wrappers']>> = [Wrapper] extends [never] ? {} : {
|
|
52
|
+
[W in Wrapper]: {
|
|
53
|
+
/**
|
|
54
|
+
* Identifier of a wrapper registered in `config[entityType].wrappers`. The
|
|
55
|
+
* wrapper component is rendered around the view in overview mode.
|
|
56
|
+
*/
|
|
57
|
+
viewWrapperType?: W;
|
|
58
|
+
/**
|
|
59
|
+
* Extra props forwarded to the selected view wrapper. Typed to the
|
|
60
|
+
* `wrapperProps` shape declared by the chosen wrapper component.
|
|
61
|
+
*/
|
|
62
|
+
viewWrapperProps?: ExtractWrapperProps<TypeConfig['wrappers'][W]>;
|
|
63
|
+
};
|
|
64
|
+
}[Wrapper];
|
|
65
|
+
type ValidatorEntityParameters<Validator extends string> = [Validator] extends [never] ? {} : {
|
|
66
|
+
[V in Validator]: {
|
|
67
|
+
/**
|
|
68
|
+
* Identifier of a custom validator registered in `config[entityType].validators`.
|
|
69
|
+
* Runs in addition to (or instead of, depending on the renderer policy) the
|
|
70
|
+
* JSON Schema validation derived from the schema keywords.
|
|
71
|
+
*
|
|
72
|
+
* TODO(verify): confirm whether the custom validator replaces or complements
|
|
73
|
+
* JSON Schema validation and adjust this comment.
|
|
74
|
+
*/
|
|
75
|
+
validatorType?: V;
|
|
76
|
+
};
|
|
77
|
+
}[Validator];
|
|
78
|
+
/**
|
|
79
|
+
* Renderer-specific configuration carried on each schema node. Not part of the
|
|
80
|
+
* JSON Schema specification — these keywords are ignored by JSON Schema
|
|
81
|
+
* validators and consumed only by SchemaRenderer to choose controls, views,
|
|
82
|
+
* wrappers, validators, and custom error messages for the field.
|
|
83
|
+
*
|
|
84
|
+
* Generic parameters bind the available `controlType` / `viewType` /
|
|
85
|
+
* `wrapperType` / `validatorType` values to those registered in the
|
|
86
|
+
* `SchemaRendererConfig` for this entity type — making invalid identifiers a
|
|
87
|
+
* TypeScript error at the schema declaration site.
|
|
88
|
+
*/
|
|
89
|
+
interface EntityParameters<Type extends EntityType, TypeConfig extends SchemaRendererConfig[Type], Control extends ObjectKeys<TypeConfig['controls']> = ObjectKeys<TypeConfig['controls']>, View extends ObjectKeys<TypeConfig['views']> = ObjectKeys<TypeConfig['views']>, Wrapper extends ObjectKeys<TypeConfig['wrappers']> = ObjectKeys<TypeConfig['wrappers']>, Validator extends ObjectKeys<TypeConfig['validators']> = ObjectKeys<TypeConfig['validators']>> {
|
|
90
|
+
/**
|
|
91
|
+
* Optional bag of renderer-specific configuration for this schema node.
|
|
92
|
+
* Ignored by JSON Schema validators.
|
|
93
|
+
*/
|
|
94
|
+
entityParameters?: {
|
|
95
|
+
/**
|
|
96
|
+
* Forces the renderer to treat this node as a specific `EntityType`, overriding
|
|
97
|
+
* the inference based on the JSON Schema `type` keyword. Useful when a single
|
|
98
|
+
* JSON type should be rendered as multiple kinds of UI (e.g. `String` rendered
|
|
99
|
+
* via different `EntityType` registrations).
|
|
100
|
+
*/
|
|
101
|
+
type?: Type;
|
|
102
|
+
/**
|
|
103
|
+
* Custom error messages shown by the renderer when validation fails. Keys
|
|
104
|
+
* correspond to JSON Schema validation keywords (`minLength`, `pattern`, `enum`,
|
|
105
|
+
* etc.).
|
|
106
|
+
*
|
|
107
|
+
* `dependencies` and `required` accept either a single string (used for any
|
|
108
|
+
* failure of that keyword) or a `Record<string, string>` mapping the dependent /
|
|
109
|
+
* required property name to its own message.
|
|
110
|
+
*
|
|
111
|
+
* Not part of the JSON Schema specification — purely a UI override for this
|
|
112
|
+
* renderer.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* {
|
|
116
|
+
* type: JsonSchemaType.String,
|
|
117
|
+
* minLength: 5,
|
|
118
|
+
* entityParameters: {
|
|
119
|
+
* errorMessages: {minLength: 'Must be at least 5 characters'},
|
|
120
|
+
* },
|
|
121
|
+
* }
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* // Per-property message for required.
|
|
125
|
+
* {
|
|
126
|
+
* type: JsonSchemaType.Object,
|
|
127
|
+
* required: ['name', 'email'],
|
|
128
|
+
* entityParameters: {
|
|
129
|
+
* errorMessages: {
|
|
130
|
+
* required: {name: 'Name is required', email: 'Email is required'},
|
|
131
|
+
* },
|
|
132
|
+
* },
|
|
133
|
+
* }
|
|
134
|
+
*/
|
|
135
|
+
errorMessages?: Omit<ErrorMessages, 'dependencies' | 'required'> & {
|
|
136
|
+
dependencies?: string | Record<string, string>;
|
|
137
|
+
required?: string | Record<string, string>;
|
|
138
|
+
};
|
|
139
|
+
} & ControlEntityParameters<TypeConfig, Control> & ControlWrapperEntityParameters<TypeConfig, Wrapper> & ViewEntityParameters<TypeConfig, View> & ViewWrapperEntityParameters<TypeConfig, Wrapper> & ValidatorEntityParameters<Validator>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Common JSON Schema keywords inherited by every concrete schema variant.
|
|
143
|
+
*/
|
|
144
|
+
interface JsonSchemaBase<Config extends SchemaRendererConfig, Schema extends JsonSchema<Config>, Value extends FieldValue> {
|
|
145
|
+
/**
|
|
146
|
+
* Unique URI identifier for the schema; establishes the base URI used to resolve
|
|
147
|
+
* relative `$ref`s in all nested sub-schemas.
|
|
148
|
+
*
|
|
149
|
+
* May be an absolute URI, a relative URI (resolved against the parent `$id`), or
|
|
150
|
+
* a fragment-only anchor (e.g. `#address`) — the anchor form lets `$ref: '#address'`
|
|
151
|
+
* point at this schema from anywhere in the document.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* { $id: 'https://example.com/schemas/person' }
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* // Anchor form: nested schemas can reference it via `{ $ref: '#address' }`.
|
|
158
|
+
* { $id: '#address', type: JsonSchemaType.Object }
|
|
159
|
+
*
|
|
160
|
+
* @see https://json-schema.org/draft-07/json-schema-core.html#rfc.section.8.2
|
|
161
|
+
*/
|
|
162
|
+
$id?: string;
|
|
163
|
+
/**
|
|
164
|
+
* URI reference to another schema. Resolved against the nearest enclosing `$id`
|
|
165
|
+
* (or the document URI). Targets may be in `definitions`, but also any nested
|
|
166
|
+
* sub-schema reachable by JSON Pointer.
|
|
167
|
+
*
|
|
168
|
+
* Draft-07 behaviour: when `$ref` is present, all sibling keywords in the same
|
|
169
|
+
* object (including `title`, `description`, and validation keywords) are
|
|
170
|
+
* **ignored** by the validator. This changed in Draft-2019-09, but the project
|
|
171
|
+
* targets Draft-07 — combining `$ref` with siblings will silently lose them.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* // JSON Pointer into definitions.
|
|
175
|
+
* { $ref: '#/definitions/positiveInt' }
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* // JSON Pointer into the middle of the schema tree.
|
|
179
|
+
* { $ref: '#/properties/user/properties/address' }
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* // External document.
|
|
183
|
+
* { $ref: 'https://example.com/schemas/address.json' }
|
|
184
|
+
*
|
|
185
|
+
* @see https://json-schema.org/draft-07/json-schema-core.html#rfc.section.8.3
|
|
186
|
+
*/
|
|
187
|
+
$ref?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Logical AND: the value must validate against every sub-schema in the list.
|
|
190
|
+
*
|
|
191
|
+
* Useful for composing reusable constraints (typically declared in `definitions`)
|
|
192
|
+
* onto a base schema. In typed variants (e.g. `JsonSchemaString`), the entries
|
|
193
|
+
* are narrowed to the same variant by design — heterogeneous composition is not
|
|
194
|
+
* representable.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* {
|
|
198
|
+
* type: JsonSchemaType.String,
|
|
199
|
+
* allOf: [{minLength: 3}, {pattern: '^[a-z]+$'}],
|
|
200
|
+
* }
|
|
201
|
+
*
|
|
202
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.7.1
|
|
203
|
+
*/
|
|
204
|
+
allOf?: Schema[];
|
|
205
|
+
/**
|
|
206
|
+
* Logical OR: the value must validate against at least one sub-schema in the list.
|
|
207
|
+
*
|
|
208
|
+
* Unlike `oneOf`, no uniqueness check — the first match is enough. Prefer `anyOf`
|
|
209
|
+
* when overlap between branches is acceptable; prefer `oneOf` when branches are
|
|
210
|
+
* disjoint and you want a "discriminated union" semantics.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* { anyOf: [{type: JsonSchemaType.String}, {type: JsonSchemaType.Number}] }
|
|
214
|
+
*
|
|
215
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.7.2
|
|
216
|
+
*/
|
|
217
|
+
anyOf?: Schema[];
|
|
218
|
+
/**
|
|
219
|
+
* Restricts the value to exactly this constant. Equivalent to `enum: [const]`.
|
|
220
|
+
*
|
|
221
|
+
* Comparison is deep structural equality — works for primitives, arrays, objects,
|
|
222
|
+
* and `null`. Two different object instances with the same shape both match.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* { type: JsonSchemaType.String, const: 'v1' }
|
|
226
|
+
*
|
|
227
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.1.3
|
|
228
|
+
*/
|
|
229
|
+
const?: Value;
|
|
230
|
+
/**
|
|
231
|
+
* Default value associated with the schema.
|
|
232
|
+
*
|
|
233
|
+
* In the JSON Schema specification this is an **annotation**, not a validation
|
|
234
|
+
* keyword — validators do not modify values by themselves. The SchemaRenderer
|
|
235
|
+
* uses it to seed the initial form value when none is supplied.
|
|
236
|
+
*
|
|
237
|
+
* Note: `default: null` is a present default of `null`, not "no default".
|
|
238
|
+
*
|
|
239
|
+
* TODO(verify): confirm exact application point in `useSchemaRenderer` and
|
|
240
|
+
* adjust this comment if the runtime treats `default` differently.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* { type: JsonSchemaType.String, default: 'guest' }
|
|
244
|
+
*
|
|
245
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.10.2
|
|
246
|
+
*/
|
|
247
|
+
default?: Value;
|
|
248
|
+
/**
|
|
249
|
+
* Map of reusable named sub-schemas. Each entry is referenced via
|
|
250
|
+
* `$ref: '#/definitions/<key>'` from anywhere in the document.
|
|
251
|
+
*
|
|
252
|
+
* Renamed to `$defs` starting in Draft-2019-09; the project targets Draft-07,
|
|
253
|
+
* so `definitions` is the canonical form.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* {
|
|
257
|
+
* definitions: {
|
|
258
|
+
* positiveInt: {type: JsonSchemaType.Number, minimum: 1},
|
|
259
|
+
* },
|
|
260
|
+
* properties: {
|
|
261
|
+
* age: {$ref: '#/definitions/positiveInt'},
|
|
262
|
+
* },
|
|
263
|
+
* }
|
|
264
|
+
*
|
|
265
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.9
|
|
266
|
+
*/
|
|
267
|
+
definitions?: {
|
|
268
|
+
[key: string]: JsonSchema<Config>;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Longer human-readable explanation of the schema. The SchemaRenderer renders it
|
|
272
|
+
* as helper/hint text near the control.
|
|
273
|
+
*
|
|
274
|
+
* Annotation only — not used for validation.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* { type: JsonSchemaType.String, description: 'As shown on your government-issued ID' }
|
|
278
|
+
*
|
|
279
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.10.1
|
|
280
|
+
*/
|
|
281
|
+
description?: string;
|
|
282
|
+
/**
|
|
283
|
+
* Sub-schema applied when the value does **not** satisfy the `if` schema.
|
|
284
|
+
*
|
|
285
|
+
* Has no effect unless paired with `if`. If both `then` and `else` are omitted,
|
|
286
|
+
* `if` is a no-op for validation.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* {
|
|
290
|
+
* if: {properties: {locale: {const: 'ja'}}},
|
|
291
|
+
* then: {required: ['kanjiName']},
|
|
292
|
+
* else: {required: ['latinName']},
|
|
293
|
+
* }
|
|
294
|
+
*
|
|
295
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.6.3
|
|
296
|
+
*/
|
|
297
|
+
else?: Schema;
|
|
298
|
+
/**
|
|
299
|
+
* Restricts the value to exactly one of the listed entries.
|
|
300
|
+
*
|
|
301
|
+
* Comparison is deep structural equality — entries may be primitives, arrays,
|
|
302
|
+
* objects, or `null`. In typed variants the entries are narrowed to the variant's
|
|
303
|
+
* value type (e.g. `string[]` for `JsonSchemaString`); for nullable fields,
|
|
304
|
+
* include `null` explicitly when needed.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* { type: JsonSchemaType.String, enum: ['draft', 'published', 'archived'] }
|
|
308
|
+
*
|
|
309
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.1.2
|
|
310
|
+
*/
|
|
311
|
+
enum?: Value[];
|
|
312
|
+
/**
|
|
313
|
+
* Sample values illustrating typical inputs. Annotation only — not used for
|
|
314
|
+
* validation.
|
|
315
|
+
*
|
|
316
|
+
* TODO(verify): document whether and where the SchemaRenderer surfaces examples
|
|
317
|
+
* in the UI; adjust the comment to match.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* { type: JsonSchemaType.String, examples: ['alice@example.com', 'bob@example.com'] }
|
|
321
|
+
*
|
|
322
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.10.4
|
|
323
|
+
*/
|
|
324
|
+
examples?: Value[];
|
|
325
|
+
/**
|
|
326
|
+
* Conditional sub-schema used together with `then` / `else`. Switches which
|
|
327
|
+
* branch is applied, but is **not** itself a validation constraint — if the
|
|
328
|
+
* value fails `if`, validation does not fail; it only routes to `else`.
|
|
329
|
+
*
|
|
330
|
+
* Without `then` or `else`, `if` is a no-op.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* {
|
|
334
|
+
* if: {properties: {locale: {const: 'ja'}}},
|
|
335
|
+
* then: {required: ['kanjiName']},
|
|
336
|
+
* }
|
|
337
|
+
*
|
|
338
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.6.1
|
|
339
|
+
*/
|
|
340
|
+
if?: Schema;
|
|
341
|
+
/**
|
|
342
|
+
* Logical NOT: the value must **not** validate against this sub-schema.
|
|
343
|
+
*
|
|
344
|
+
* Common pitfall: `not: {}` disallows every value (the empty schema accepts
|
|
345
|
+
* everything, so its negation accepts nothing).
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* { type: JsonSchemaType.String, not: {const: 'forbidden'} }
|
|
349
|
+
*
|
|
350
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.7.4
|
|
351
|
+
*/
|
|
352
|
+
not?: Schema;
|
|
353
|
+
/**
|
|
354
|
+
* Logical XOR: the value must validate against **exactly one** sub-schema —
|
|
355
|
+
* matching zero or two-or-more fails.
|
|
356
|
+
*
|
|
357
|
+
* Use for discriminated-union semantics where branches are disjoint. If
|
|
358
|
+
* branches overlap, prefer `anyOf` — `oneOf` will reject values that match
|
|
359
|
+
* more than one branch.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* {
|
|
363
|
+
* oneOf: [
|
|
364
|
+
* {type: JsonSchemaType.String, maxLength: 5},
|
|
365
|
+
* {type: JsonSchemaType.String, minLength: 10},
|
|
366
|
+
* ],
|
|
367
|
+
* }
|
|
368
|
+
*
|
|
369
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.7.3
|
|
370
|
+
*/
|
|
371
|
+
oneOf?: Schema[];
|
|
372
|
+
/**
|
|
373
|
+
* Marks the value as read-only. Per the JSON Schema spec this is an annotation;
|
|
374
|
+
* the SchemaRenderer disables the control for editing but keeps the existing
|
|
375
|
+
* value in the form payload.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* { type: JsonSchemaType.String, readOnly: true }
|
|
379
|
+
*
|
|
380
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.10.3
|
|
381
|
+
*/
|
|
382
|
+
readOnly?: boolean;
|
|
383
|
+
/**
|
|
384
|
+
* Sub-schema applied when the value satisfies the `if` schema. Has no effect
|
|
385
|
+
* unless paired with `if`.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* {
|
|
389
|
+
* if: {properties: {locale: {const: 'ja'}}},
|
|
390
|
+
* then: {required: ['kanjiName']},
|
|
391
|
+
* }
|
|
392
|
+
*
|
|
393
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.6.2
|
|
394
|
+
*/
|
|
395
|
+
then?: Schema;
|
|
396
|
+
/**
|
|
397
|
+
* Short human-readable label for the schema. The SchemaRenderer renders it as
|
|
398
|
+
* the control's label; when omitted, the property name is typically used as a
|
|
399
|
+
* fallback.
|
|
400
|
+
*
|
|
401
|
+
* Annotation only — not used for validation.
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* { type: JsonSchemaType.String, title: 'First name' }
|
|
405
|
+
*
|
|
406
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.10.1
|
|
407
|
+
*/
|
|
408
|
+
title?: string;
|
|
409
|
+
/**
|
|
410
|
+
* Marks the value as write-only — meant to be submitted but not echoed back
|
|
411
|
+
* (e.g. passwords). The SchemaRenderer typically hides the value in overview /
|
|
412
|
+
* read mode while still accepting input in form mode.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* { type: JsonSchemaType.String, writeOnly: true }
|
|
416
|
+
*
|
|
417
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.10.3
|
|
418
|
+
*/
|
|
419
|
+
writeOnly?: boolean;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Schema variant without an explicit `type` keyword. Matches values of any JSON type and accepts every keyword from the typed variants.
|
|
423
|
+
*/
|
|
424
|
+
export interface JsonSchemaAny<Config extends SchemaRendererConfig = any> extends JsonSchemaBase<Config, JsonSchema<Config>, FieldValue>, EntityParameters<EntityType.Any, Config[EntityType.Any]> {
|
|
425
|
+
/**
|
|
426
|
+
* Optional declared JSON type(s). When omitted, the schema matches any JSON type
|
|
427
|
+
* and every keyword from the typed variants is accepted (each behaving according
|
|
428
|
+
* to the actual runtime type — see "ignored for non-X values" below).
|
|
429
|
+
*
|
|
430
|
+
* A string array narrows to a union of allowed types. Include `JsonSchemaType.Null`
|
|
431
|
+
* to allow `null` values.
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* // Matches any value, but constrains it to one of a few specific values.
|
|
435
|
+
* { enum: ['yes', 1, true] }
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* // Union — string or null.
|
|
439
|
+
* { type: [JsonSchemaType.String, JsonSchemaType.Null] }
|
|
440
|
+
*
|
|
441
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.1.1
|
|
442
|
+
*/
|
|
443
|
+
type?: JsonSchemaType | JsonSchemaType[];
|
|
444
|
+
/**
|
|
445
|
+
* Schema applied to array items beyond the positional tuple defined by `items`;
|
|
446
|
+
* ignored for non-array values, and ignored entirely when `items` is a single
|
|
447
|
+
* schema (only meaningful when `items` is an array — tuple validation).
|
|
448
|
+
*
|
|
449
|
+
* - `true` (default if omitted): any additional items are allowed.
|
|
450
|
+
* - `false`: array length must not exceed the tuple defined by `items`.
|
|
451
|
+
* - schema: every additional item must validate against it.
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* // Tuple of one string; no further items allowed.
|
|
455
|
+
* { items: [{type: JsonSchemaType.String}], additionalItems: false }
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* // Tuple of one string; further items must be numbers.
|
|
459
|
+
* { items: [{type: JsonSchemaType.String}], additionalItems: {type: JsonSchemaType.Number} }
|
|
460
|
+
*
|
|
461
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.2
|
|
462
|
+
*/
|
|
463
|
+
additionalItems?: JsonSchema<Config> | boolean;
|
|
464
|
+
/**
|
|
465
|
+
* Schema applied to object properties not listed in `properties` and not matched
|
|
466
|
+
* by any `patternProperties` key; ignored for non-object values.
|
|
467
|
+
*
|
|
468
|
+
* - `true` (default if omitted): any extra properties are allowed.
|
|
469
|
+
* - `false`: extra properties cause validation to fail.
|
|
470
|
+
* - schema: every extra property's value must validate against it.
|
|
471
|
+
*
|
|
472
|
+
* Interacts with `properties` and `patternProperties` — a property is "additional"
|
|
473
|
+
* only if it matches **neither** set.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* { properties: {name: {type: JsonSchemaType.String}}, additionalProperties: false }
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* { properties: {name: {type: JsonSchemaType.String}}, additionalProperties: {type: JsonSchemaType.Number} }
|
|
480
|
+
*
|
|
481
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.6
|
|
482
|
+
*/
|
|
483
|
+
additionalProperties?: JsonSchema<Config> | boolean;
|
|
484
|
+
/**
|
|
485
|
+
* Sub-schema that **at least one** array item must satisfy; ignored for non-array
|
|
486
|
+
* values. An empty array always fails `contains`.
|
|
487
|
+
*
|
|
488
|
+
* Draft-07 note: per the spec the value must be a schema; the `boolean` form is
|
|
489
|
+
* a Draft-2019-09 addition (`true` accepts any non-empty array, `false` always
|
|
490
|
+
* fails). The current `boolean` typing here is more permissive than Draft-07.
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* { contains: {type: JsonSchemaType.Number, minimum: 5} }
|
|
494
|
+
*
|
|
495
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.6
|
|
496
|
+
*/
|
|
497
|
+
contains?: JsonSchema<Config> | boolean;
|
|
498
|
+
/**
|
|
499
|
+
* Property dependencies on an object value; ignored for non-object values.
|
|
500
|
+
* Each key triggers a constraint only when that property is present in the value.
|
|
501
|
+
*
|
|
502
|
+
* Two forms per entry:
|
|
503
|
+
* - `string[]` — the listed property names must also be present.
|
|
504
|
+
* - schema — the whole object must additionally validate against the given schema.
|
|
505
|
+
*
|
|
506
|
+
* Split into `dependentRequired` and `dependentSchemas` in Draft-2019-09 — the
|
|
507
|
+
* project targets Draft-07, so the combined form is used here.
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* // Required-name form.
|
|
511
|
+
* { dependencies: {credit_card: ['billing_address']} }
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* // Schema form.
|
|
515
|
+
* { dependencies: {credit_card: {required: ['billing_address']}} }
|
|
516
|
+
*
|
|
517
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.7
|
|
518
|
+
*/
|
|
519
|
+
dependencies?: {
|
|
520
|
+
[key: string]: string[] | JsonSchema<Config>;
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* Strict upper bound for numeric values (value must be strictly less than this);
|
|
524
|
+
* ignored for non-numeric values.
|
|
525
|
+
*
|
|
526
|
+
* Draft-07 typing — a `number`. (In Draft-04 this keyword was a `boolean` modifier
|
|
527
|
+
* for `maximum`; that form is not supported here.)
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* { exclusiveMaximum: 100 }
|
|
531
|
+
*
|
|
532
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.3
|
|
533
|
+
*/
|
|
534
|
+
exclusiveMaximum?: number;
|
|
535
|
+
/**
|
|
536
|
+
* Strict lower bound for numeric values (value must be strictly greater than
|
|
537
|
+
* this); ignored for non-numeric values.
|
|
538
|
+
*
|
|
539
|
+
* Draft-07 typing — a `number`. (In Draft-04 this keyword was a `boolean` modifier
|
|
540
|
+
* for `minimum`; that form is not supported here.)
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* { exclusiveMinimum: 0 }
|
|
544
|
+
*
|
|
545
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.5
|
|
546
|
+
*/
|
|
547
|
+
exclusiveMinimum?: number;
|
|
548
|
+
/**
|
|
549
|
+
* Constrains array items; ignored for non-array values. Two forms:
|
|
550
|
+
*
|
|
551
|
+
* - **Single schema** — every array item must validate against it. `additionalItems`
|
|
552
|
+
* is ignored in this form.
|
|
553
|
+
* - **Tuple (array of schemas)** — positional validation: item at index `i` must
|
|
554
|
+
* validate against `items[i]`. Items beyond the tuple are governed by
|
|
555
|
+
* `additionalItems` (default: any are allowed).
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* // Single schema — homogeneous array.
|
|
559
|
+
* { items: {type: JsonSchemaType.String} }
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* // Tuple — first item string, second item number.
|
|
563
|
+
* { items: [{type: JsonSchemaType.String}, {type: JsonSchemaType.Number}] }
|
|
564
|
+
*
|
|
565
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.1
|
|
566
|
+
*/
|
|
567
|
+
items?: JsonSchema<Config> | JsonSchema<Config>[];
|
|
568
|
+
/**
|
|
569
|
+
* Inclusive upper bound for numeric values; ignored for non-numeric values.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* { maximum: 100 }
|
|
573
|
+
*
|
|
574
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.2
|
|
575
|
+
*/
|
|
576
|
+
maximum?: number;
|
|
577
|
+
/**
|
|
578
|
+
* Maximum number of items the array may contain; ignored for non-array values.
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* { maxItems: 10 }
|
|
582
|
+
*
|
|
583
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.3
|
|
584
|
+
*/
|
|
585
|
+
maxItems?: number;
|
|
586
|
+
/**
|
|
587
|
+
* Longest allowed string length; ignored for non-string values.
|
|
588
|
+
*
|
|
589
|
+
* Length is counted in **UTF-16 code units** (matching `String.prototype.length`
|
|
590
|
+
* in JS), not user-perceived characters. Characters outside the BMP — including
|
|
591
|
+
* many emoji — count as 2.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* { maxLength: 100 }
|
|
595
|
+
*
|
|
596
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.3.1
|
|
597
|
+
*/
|
|
598
|
+
maxLength?: number;
|
|
599
|
+
/**
|
|
600
|
+
* Maximum number of own properties the object may declare; ignored for non-object
|
|
601
|
+
* values.
|
|
602
|
+
*
|
|
603
|
+
* @example
|
|
604
|
+
* { maxProperties: 5 }
|
|
605
|
+
*
|
|
606
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.1
|
|
607
|
+
*/
|
|
608
|
+
maxProperties?: number;
|
|
609
|
+
/**
|
|
610
|
+
* Inclusive lower bound for numeric values; ignored for non-numeric values.
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* { minimum: 0 }
|
|
614
|
+
*
|
|
615
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.4
|
|
616
|
+
*/
|
|
617
|
+
minimum?: number;
|
|
618
|
+
/**
|
|
619
|
+
* Minimum number of items the array must contain; ignored for non-array values.
|
|
620
|
+
*
|
|
621
|
+
* @example
|
|
622
|
+
* { minItems: 1 }
|
|
623
|
+
*
|
|
624
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.4
|
|
625
|
+
*/
|
|
626
|
+
minItems?: number;
|
|
627
|
+
/**
|
|
628
|
+
* Shortest allowed string length; ignored for non-string values.
|
|
629
|
+
*
|
|
630
|
+
* Length is counted in **UTF-16 code units** (matching `String.prototype.length`
|
|
631
|
+
* in JS), not user-perceived characters. Characters outside the BMP — including
|
|
632
|
+
* many emoji — count as 2.
|
|
633
|
+
*
|
|
634
|
+
* @example
|
|
635
|
+
* { minLength: 5 }
|
|
636
|
+
*
|
|
637
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.3.2
|
|
638
|
+
*/
|
|
639
|
+
minLength?: number;
|
|
640
|
+
/**
|
|
641
|
+
* Minimum number of own properties the object must declare; ignored for non-object
|
|
642
|
+
* values.
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* { minProperties: 1 }
|
|
646
|
+
*
|
|
647
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.2
|
|
648
|
+
*/
|
|
649
|
+
minProperties?: number;
|
|
650
|
+
/**
|
|
651
|
+
* Numeric value must be an exact multiple of this number; ignored for non-numeric
|
|
652
|
+
* values. The divisor must be strictly greater than 0.
|
|
653
|
+
*
|
|
654
|
+
* Supports fractional steppers (e.g. `0.25`). Watch for IEEE-754 representation:
|
|
655
|
+
* `0.1 + 0.2 !== 0.3`. AJV uses an epsilon-tolerant comparison, but constructing
|
|
656
|
+
* the value via repeated addition in JS may still produce an unexpected mismatch.
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* { multipleOf: 0.25 }
|
|
660
|
+
*
|
|
661
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.1
|
|
662
|
+
*/
|
|
663
|
+
multipleOf?: number;
|
|
664
|
+
/**
|
|
665
|
+
* ECMA-262 regular expression the string value must match; ignored for non-string
|
|
666
|
+
* values.
|
|
667
|
+
*
|
|
668
|
+
* **No implicit anchors** — the pattern matches if it can be found anywhere in
|
|
669
|
+
* the string. To require a full match, anchor explicitly with `^` and `$`.
|
|
670
|
+
* Common pitfall: `'[0-9]'` means "contains a digit", not "consists of digits".
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* // Matches any string that contains at least one digit.
|
|
674
|
+
* { pattern: '[0-9]' }
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* // Matches a capitalised word from start to end.
|
|
678
|
+
* { pattern: '^[A-Z][a-z]+$' }
|
|
679
|
+
*
|
|
680
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.3.3
|
|
681
|
+
*/
|
|
682
|
+
pattern?: string;
|
|
683
|
+
/**
|
|
684
|
+
* Map of regular-expression keys to schemas; ignored for non-object values.
|
|
685
|
+
* Each property whose name matches a key must validate against the corresponding
|
|
686
|
+
* schema.
|
|
687
|
+
*
|
|
688
|
+
* A property name may match **several** patterns at once — in that case it must
|
|
689
|
+
* validate against **all** matching schemas (allOf-like semantics).
|
|
690
|
+
*
|
|
691
|
+
* Interacts with `properties` (an explicit match wins for that name) and
|
|
692
|
+
* `additionalProperties` (a property is "additional" only if it matches no
|
|
693
|
+
* `properties` key **and** no `patternProperties` key).
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* { patternProperties: {'^x-': {type: JsonSchemaType.String}} }
|
|
697
|
+
*
|
|
698
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.5
|
|
699
|
+
*/
|
|
700
|
+
patternProperties?: {
|
|
701
|
+
[key: string]: JsonSchema<Config>;
|
|
702
|
+
};
|
|
703
|
+
/**
|
|
704
|
+
* Map of property name to schema. Each listed property's value must validate
|
|
705
|
+
* against the corresponding schema; ignored for non-object values.
|
|
706
|
+
*
|
|
707
|
+
* Declaring a property here does **not** make it required — pair with `required`.
|
|
708
|
+
* Properties not listed here are governed by `patternProperties` /
|
|
709
|
+
* `additionalProperties`.
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* { properties: {name: {type: JsonSchemaType.String}} }
|
|
713
|
+
*
|
|
714
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.4
|
|
715
|
+
*/
|
|
716
|
+
properties?: {
|
|
717
|
+
[key: string]: JsonSchema<Config>;
|
|
718
|
+
};
|
|
719
|
+
/**
|
|
720
|
+
* Schema each property **name** must satisfy; ignored for non-object values.
|
|
721
|
+
* Object keys are always strings, so this is typed as `JsonSchemaString`.
|
|
722
|
+
*
|
|
723
|
+
* Validates names only — property values are unaffected.
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* { propertyNames: {pattern: '^[a-z][a-zA-Z0-9]*$'} }
|
|
727
|
+
*
|
|
728
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.8
|
|
729
|
+
*/
|
|
730
|
+
propertyNames?: JsonSchemaString<Config>;
|
|
731
|
+
/**
|
|
732
|
+
* Names of properties that must be present on the object value; ignored for
|
|
733
|
+
* non-object values.
|
|
734
|
+
*
|
|
735
|
+
* A name may appear in `required` even if it is not declared in `properties` —
|
|
736
|
+
* then the property must be present but has no schema applied.
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* {
|
|
740
|
+
* properties: {name: {type: JsonSchemaType.String}},
|
|
741
|
+
* required: ['name'],
|
|
742
|
+
* }
|
|
743
|
+
*
|
|
744
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.3
|
|
745
|
+
*/
|
|
746
|
+
required?: string[];
|
|
747
|
+
/**
|
|
748
|
+
* When `true`, every array item must be unique; ignored for non-array values.
|
|
749
|
+
*
|
|
750
|
+
* Uniqueness is by deep structural equality (so `{a: 1}` and `{a: 1}` are equal).
|
|
751
|
+
* On large arrays this is O(n²) — be mindful when constraining big lists.
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* { uniqueItems: true }
|
|
755
|
+
*
|
|
756
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.5
|
|
757
|
+
*/
|
|
758
|
+
uniqueItems?: boolean;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Schema for array values (`type: JsonSchemaType.Array`).
|
|
762
|
+
*/
|
|
763
|
+
export interface JsonSchemaArray<Config extends SchemaRendererConfig = any> extends JsonSchemaBase<Config, JsonSchemaArray<Config>, ArrayValue>, EntityParameters<EntityType.Array, Config[EntityType.Array]> {
|
|
764
|
+
/**
|
|
765
|
+
* Declares this schema as describing an array value (or `null`, or a union of
|
|
766
|
+
* the two for nullable arrays).
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* { type: JsonSchemaType.Array, items: {type: JsonSchemaType.String} }
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* // Nullable array.
|
|
773
|
+
* { type: [JsonSchemaType.Array, JsonSchemaType.Null] }
|
|
774
|
+
*
|
|
775
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.1.1
|
|
776
|
+
*/
|
|
777
|
+
type?: JsonSchemaType.Array | JsonSchemaType.Null | (JsonSchemaType.Array | JsonSchemaType.Null)[];
|
|
778
|
+
/**
|
|
779
|
+
* Schema applied to array items beyond the positional tuple defined by `items`.
|
|
780
|
+
* Only meaningful when `items` is an array (tuple); ignored when `items` is a
|
|
781
|
+
* single schema.
|
|
782
|
+
*
|
|
783
|
+
* - `true` (default if omitted): any additional items are allowed.
|
|
784
|
+
* - `false`: array length must not exceed the tuple defined by `items`.
|
|
785
|
+
* - schema: every additional item must validate against it.
|
|
786
|
+
*
|
|
787
|
+
* @example
|
|
788
|
+
* { items: [{type: JsonSchemaType.String}], additionalItems: false }
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* { items: [{type: JsonSchemaType.String}], additionalItems: {type: JsonSchemaType.Number} }
|
|
792
|
+
*
|
|
793
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.2
|
|
794
|
+
*/
|
|
795
|
+
additionalItems?: JsonSchema<Config> | boolean;
|
|
796
|
+
/**
|
|
797
|
+
* Sub-schema that **at least one** array item must satisfy. An empty array
|
|
798
|
+
* always fails `contains`.
|
|
799
|
+
*
|
|
800
|
+
* Draft-07 note: per the spec the value must be a schema; the `boolean` form is
|
|
801
|
+
* a Draft-2019-09 addition. The current `boolean` typing here is more permissive
|
|
802
|
+
* than Draft-07.
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* { contains: {type: JsonSchemaType.Number, minimum: 5} }
|
|
806
|
+
*
|
|
807
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.6
|
|
808
|
+
*/
|
|
809
|
+
contains?: JsonSchema<Config> | boolean;
|
|
810
|
+
/**
|
|
811
|
+
* Constrains array items. Two forms:
|
|
812
|
+
*
|
|
813
|
+
* - **Single schema** — every array item must validate against it. `additionalItems`
|
|
814
|
+
* is ignored in this form.
|
|
815
|
+
* - **Tuple (array of schemas)** — positional validation: item at index `i` must
|
|
816
|
+
* validate against `items[i]`. Items beyond the tuple are governed by
|
|
817
|
+
* `additionalItems`.
|
|
818
|
+
*
|
|
819
|
+
* @example
|
|
820
|
+
* { items: {type: JsonSchemaType.String} }
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* { items: [{type: JsonSchemaType.String}, {type: JsonSchemaType.Number}] }
|
|
824
|
+
*
|
|
825
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.1
|
|
826
|
+
*/
|
|
827
|
+
items?: JsonSchema<Config> | JsonSchema<Config>[];
|
|
828
|
+
/**
|
|
829
|
+
* Maximum number of items the array may contain.
|
|
830
|
+
*
|
|
831
|
+
* @example
|
|
832
|
+
* { maxItems: 10 }
|
|
833
|
+
*
|
|
834
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.3
|
|
835
|
+
*/
|
|
836
|
+
maxItems?: number;
|
|
837
|
+
/**
|
|
838
|
+
* Minimum number of items the array must contain.
|
|
839
|
+
*
|
|
840
|
+
* @example
|
|
841
|
+
* { minItems: 1 }
|
|
842
|
+
*
|
|
843
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.4
|
|
844
|
+
*/
|
|
845
|
+
minItems?: number;
|
|
846
|
+
/**
|
|
847
|
+
* When `true`, every array item must be unique.
|
|
848
|
+
*
|
|
849
|
+
* Uniqueness is by deep structural equality. On large arrays this is O(n²) —
|
|
850
|
+
* be mindful when constraining big lists.
|
|
851
|
+
*
|
|
852
|
+
* @example
|
|
853
|
+
* { uniqueItems: true }
|
|
854
|
+
*
|
|
855
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.4.5
|
|
856
|
+
*/
|
|
857
|
+
uniqueItems?: boolean;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Schema for boolean values (`type: JsonSchemaType.Boolean`).
|
|
861
|
+
*/
|
|
862
|
+
export interface JsonSchemaBoolean<Config extends SchemaRendererConfig = any> extends JsonSchemaBase<Config, JsonSchemaBoolean<Config>, boolean>, EntityParameters<EntityType.Boolean, Config[EntityType.Boolean]> {
|
|
863
|
+
/**
|
|
864
|
+
* Declares this schema as describing a boolean value (or `null`, or a union of
|
|
865
|
+
* the two for nullable booleans).
|
|
866
|
+
*
|
|
867
|
+
* @example
|
|
868
|
+
* { type: JsonSchemaType.Boolean, default: false }
|
|
869
|
+
*
|
|
870
|
+
* @example
|
|
871
|
+
* // Nullable boolean.
|
|
872
|
+
* { type: [JsonSchemaType.Boolean, JsonSchemaType.Null] }
|
|
873
|
+
*
|
|
874
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.1.1
|
|
875
|
+
*/
|
|
876
|
+
type?: JsonSchemaType.Boolean | JsonSchemaType.Null | (JsonSchemaType.Boolean | JsonSchemaType.Null)[];
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Schema for numeric values (`type: JsonSchemaType.Number`).
|
|
880
|
+
*/
|
|
881
|
+
export interface JsonSchemaNumber<Config extends SchemaRendererConfig = any> extends JsonSchemaBase<Config, JsonSchemaNumber<Config>, number>, EntityParameters<EntityType.Number, Config[EntityType.Number]> {
|
|
882
|
+
/**
|
|
883
|
+
* Declares this schema as describing a numeric value.
|
|
884
|
+
*
|
|
885
|
+
* - `Number` — any JSON number (integer or decimal).
|
|
886
|
+
* - `Integer` — numbers with no fractional part (equivalent to combining `Number`
|
|
887
|
+
* with `multipleOf: 1`).
|
|
888
|
+
* - `Null` — allows `null`; combine in an array for nullable numbers.
|
|
889
|
+
*
|
|
890
|
+
* @example
|
|
891
|
+
* { type: JsonSchemaType.Number, minimum: 0, maximum: 100 }
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* // Integer-only, nullable.
|
|
895
|
+
* { type: [JsonSchemaType.Integer, JsonSchemaType.Null] }
|
|
896
|
+
*
|
|
897
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.1.1
|
|
898
|
+
*/
|
|
899
|
+
type?: JsonSchemaType.Number | JsonSchemaType.Integer | JsonSchemaType.Null | (JsonSchemaType.Number | JsonSchemaType.Integer | JsonSchemaType.Null)[];
|
|
900
|
+
/**
|
|
901
|
+
* Strict upper bound (value must be strictly less than this).
|
|
902
|
+
*
|
|
903
|
+
* Draft-07 typing — a `number`. (In Draft-04 this keyword was a `boolean` modifier
|
|
904
|
+
* for `maximum`; that form is not supported here.)
|
|
905
|
+
*
|
|
906
|
+
* @example
|
|
907
|
+
* { type: JsonSchemaType.Number, exclusiveMaximum: 100 }
|
|
908
|
+
*
|
|
909
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.3
|
|
910
|
+
*/
|
|
911
|
+
exclusiveMaximum?: number;
|
|
912
|
+
/**
|
|
913
|
+
* Strict lower bound (value must be strictly greater than this).
|
|
914
|
+
*
|
|
915
|
+
* Draft-07 typing — a `number`. (In Draft-04 this keyword was a `boolean` modifier
|
|
916
|
+
* for `minimum`; that form is not supported here.)
|
|
917
|
+
*
|
|
918
|
+
* @example
|
|
919
|
+
* { type: JsonSchemaType.Number, exclusiveMinimum: 0 }
|
|
920
|
+
*
|
|
921
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.5
|
|
922
|
+
*/
|
|
923
|
+
exclusiveMinimum?: number;
|
|
924
|
+
/**
|
|
925
|
+
* Inclusive upper bound.
|
|
926
|
+
*
|
|
927
|
+
* @example
|
|
928
|
+
* { type: JsonSchemaType.Number, maximum: 100 }
|
|
929
|
+
*
|
|
930
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.2
|
|
931
|
+
*/
|
|
932
|
+
maximum?: number;
|
|
933
|
+
/**
|
|
934
|
+
* Inclusive lower bound.
|
|
935
|
+
*
|
|
936
|
+
* @example
|
|
937
|
+
* { type: JsonSchemaType.Number, minimum: 0 }
|
|
938
|
+
*
|
|
939
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.4
|
|
940
|
+
*/
|
|
941
|
+
minimum?: number;
|
|
942
|
+
/**
|
|
943
|
+
* Value must be an exact multiple of this number. The divisor must be strictly
|
|
944
|
+
* greater than 0.
|
|
945
|
+
*
|
|
946
|
+
* Supports fractional steppers (e.g. `0.25`). Watch for IEEE-754 representation:
|
|
947
|
+
* `0.1 + 0.2 !== 0.3`. AJV uses an epsilon-tolerant comparison, but constructing
|
|
948
|
+
* the value via repeated addition in JS may still produce an unexpected mismatch.
|
|
949
|
+
*
|
|
950
|
+
* @example
|
|
951
|
+
* { type: JsonSchemaType.Number, multipleOf: 0.5 }
|
|
952
|
+
*
|
|
953
|
+
* @example
|
|
954
|
+
* { type: JsonSchemaType.Number, multipleOf: 10 }
|
|
955
|
+
*
|
|
956
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.2.1
|
|
957
|
+
*/
|
|
958
|
+
multipleOf?: number;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Schema for object values (`type: JsonSchemaType.Object`).
|
|
962
|
+
*/
|
|
963
|
+
export interface JsonSchemaObject<Config extends SchemaRendererConfig = any> extends JsonSchemaBase<Config, JsonSchemaObject<Config>, ObjectValue>, EntityParameters<EntityType.Object, Config[EntityType.Object]> {
|
|
964
|
+
/**
|
|
965
|
+
* Declares this schema as describing an object value (or `null`, or a union of
|
|
966
|
+
* the two for nullable objects).
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* { type: JsonSchemaType.Object, properties: {name: {type: JsonSchemaType.String}} }
|
|
970
|
+
*
|
|
971
|
+
* @example
|
|
972
|
+
* // Nullable object.
|
|
973
|
+
* { type: [JsonSchemaType.Object, JsonSchemaType.Null] }
|
|
974
|
+
*
|
|
975
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.1.1
|
|
976
|
+
*/
|
|
977
|
+
type?: JsonSchemaType.Object | JsonSchemaType.Null | (JsonSchemaType.Object | JsonSchemaType.Null)[];
|
|
978
|
+
/**
|
|
979
|
+
* Schema applied to properties not listed in `properties` and not matched by any
|
|
980
|
+
* `patternProperties` key.
|
|
981
|
+
*
|
|
982
|
+
* - `true` (default if omitted): any extra properties are allowed.
|
|
983
|
+
* - `false`: extra properties cause validation to fail.
|
|
984
|
+
* - schema: every extra property's value must validate against it.
|
|
985
|
+
*
|
|
986
|
+
* A property is "additional" only if it matches **neither** `properties` nor
|
|
987
|
+
* `patternProperties`.
|
|
988
|
+
*
|
|
989
|
+
* @example
|
|
990
|
+
* {
|
|
991
|
+
* properties: {name: {type: JsonSchemaType.String}},
|
|
992
|
+
* additionalProperties: false,
|
|
993
|
+
* }
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* {
|
|
997
|
+
* properties: {name: {type: JsonSchemaType.String}},
|
|
998
|
+
* additionalProperties: {type: JsonSchemaType.Number},
|
|
999
|
+
* }
|
|
1000
|
+
*
|
|
1001
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.6
|
|
1002
|
+
*/
|
|
1003
|
+
additionalProperties?: JsonSchema<Config> | boolean;
|
|
1004
|
+
/**
|
|
1005
|
+
* Property dependencies. Each key triggers a constraint only when that property
|
|
1006
|
+
* is present in the value.
|
|
1007
|
+
*
|
|
1008
|
+
* Two forms per entry:
|
|
1009
|
+
* - `string[]` — the listed property names must also be present.
|
|
1010
|
+
* - schema (an object schema) — the whole object must additionally validate
|
|
1011
|
+
* against the given schema.
|
|
1012
|
+
*
|
|
1013
|
+
* Split into `dependentRequired` and `dependentSchemas` in Draft-2019-09 — the
|
|
1014
|
+
* project targets Draft-07, so the combined form is used here.
|
|
1015
|
+
*
|
|
1016
|
+
* @example
|
|
1017
|
+
* { dependencies: {credit_card: ['billing_address']} }
|
|
1018
|
+
*
|
|
1019
|
+
* @example
|
|
1020
|
+
* { dependencies: {credit_card: {required: ['billing_address']}} }
|
|
1021
|
+
*
|
|
1022
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.7
|
|
1023
|
+
*/
|
|
1024
|
+
dependencies?: {
|
|
1025
|
+
[key: string]: string[] | JsonSchemaObject<Config>;
|
|
1026
|
+
};
|
|
1027
|
+
/**
|
|
1028
|
+
* Maximum number of own properties the object may declare.
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* { type: JsonSchemaType.Object, maxProperties: 5 }
|
|
1032
|
+
*
|
|
1033
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.1
|
|
1034
|
+
*/
|
|
1035
|
+
maxProperties?: number;
|
|
1036
|
+
/**
|
|
1037
|
+
* Minimum number of own properties the object must declare.
|
|
1038
|
+
*
|
|
1039
|
+
* @example
|
|
1040
|
+
* { type: JsonSchemaType.Object, minProperties: 1 }
|
|
1041
|
+
*
|
|
1042
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.2
|
|
1043
|
+
*/
|
|
1044
|
+
minProperties?: number;
|
|
1045
|
+
/**
|
|
1046
|
+
* Map of regular-expression keys to schemas. Each property whose name matches a
|
|
1047
|
+
* key must validate against the corresponding schema.
|
|
1048
|
+
*
|
|
1049
|
+
* A property name may match several patterns at once — in that case it must
|
|
1050
|
+
* validate against **all** matching schemas (allOf-like semantics).
|
|
1051
|
+
*
|
|
1052
|
+
* Interacts with `properties` (an explicit match wins for that name) and
|
|
1053
|
+
* `additionalProperties` (a property is "additional" only if it matches no
|
|
1054
|
+
* `properties` key **and** no `patternProperties` key).
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* { patternProperties: {'^x-': {type: JsonSchemaType.String}} }
|
|
1058
|
+
*
|
|
1059
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.5
|
|
1060
|
+
*/
|
|
1061
|
+
patternProperties?: {
|
|
1062
|
+
[key: string]: JsonSchema<Config>;
|
|
1063
|
+
};
|
|
1064
|
+
/**
|
|
1065
|
+
* Map of property name to schema. Each listed property's value must validate
|
|
1066
|
+
* against the corresponding schema.
|
|
1067
|
+
*
|
|
1068
|
+
* Declaring a property here does **not** make it required — pair with `required`.
|
|
1069
|
+
* Properties not listed here are governed by `patternProperties` /
|
|
1070
|
+
* `additionalProperties`.
|
|
1071
|
+
*
|
|
1072
|
+
* @example
|
|
1073
|
+
* {
|
|
1074
|
+
* properties: {
|
|
1075
|
+
* name: {type: JsonSchemaType.String},
|
|
1076
|
+
* age: {type: JsonSchemaType.Number},
|
|
1077
|
+
* },
|
|
1078
|
+
* }
|
|
1079
|
+
*
|
|
1080
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.4
|
|
1081
|
+
*/
|
|
1082
|
+
properties?: {
|
|
1083
|
+
[key: string]: JsonSchema<Config>;
|
|
1084
|
+
};
|
|
1085
|
+
/**
|
|
1086
|
+
* Schema each property **name** must satisfy. Object keys are always strings, so
|
|
1087
|
+
* in practice this should be a string schema constraining length or pattern.
|
|
1088
|
+
*
|
|
1089
|
+
* Validates names only — property values are unaffected.
|
|
1090
|
+
*
|
|
1091
|
+
* @example
|
|
1092
|
+
* { propertyNames: {type: JsonSchemaType.String, pattern: '^[a-z][a-zA-Z0-9]*$'} }
|
|
1093
|
+
*
|
|
1094
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.8
|
|
1095
|
+
*/
|
|
1096
|
+
propertyNames?: JsonSchema<Config>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Names of properties that must be present on the object value.
|
|
1099
|
+
*
|
|
1100
|
+
* A name may appear in `required` even if it is not declared in `properties` —
|
|
1101
|
+
* then the property must be present but has no schema applied.
|
|
1102
|
+
*
|
|
1103
|
+
* @example
|
|
1104
|
+
* {
|
|
1105
|
+
* properties: {name: {type: JsonSchemaType.String}},
|
|
1106
|
+
* required: ['name'],
|
|
1107
|
+
* }
|
|
1108
|
+
*
|
|
1109
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.5.3
|
|
1110
|
+
*/
|
|
1111
|
+
required?: string[];
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Schema for string values (`type: JsonSchemaType.String`).
|
|
1115
|
+
*/
|
|
1116
|
+
export interface JsonSchemaString<Config extends SchemaRendererConfig = any> extends JsonSchemaBase<Config, JsonSchemaString<Config>, string>, EntityParameters<EntityType.String, Config[EntityType.String]> {
|
|
1117
|
+
/**
|
|
1118
|
+
* Declares this schema as describing a string value (or `null`, or a union of
|
|
1119
|
+
* the two for nullable strings).
|
|
1120
|
+
*
|
|
1121
|
+
* @example
|
|
1122
|
+
* { type: JsonSchemaType.String, minLength: 1 }
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* // Nullable string.
|
|
1126
|
+
* { type: [JsonSchemaType.String, JsonSchemaType.Null] }
|
|
1127
|
+
*
|
|
1128
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.1.1
|
|
1129
|
+
*/
|
|
1130
|
+
type?: JsonSchemaType.String | JsonSchemaType.Null | (JsonSchemaType.String | JsonSchemaType.Null)[];
|
|
1131
|
+
/**
|
|
1132
|
+
* Longest allowed string length.
|
|
1133
|
+
*
|
|
1134
|
+
* Length is counted in **UTF-16 code units** (matching `String.prototype.length`
|
|
1135
|
+
* in JS), not user-perceived characters. Characters outside the BMP — including
|
|
1136
|
+
* many emoji — count as 2.
|
|
1137
|
+
*
|
|
1138
|
+
* @example
|
|
1139
|
+
* { type: JsonSchemaType.String, maxLength: 100 }
|
|
1140
|
+
*
|
|
1141
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.3.1
|
|
1142
|
+
*/
|
|
1143
|
+
maxLength?: number;
|
|
1144
|
+
/**
|
|
1145
|
+
* Shortest allowed string length.
|
|
1146
|
+
*
|
|
1147
|
+
* Length is counted in **UTF-16 code units** (matching `String.prototype.length`
|
|
1148
|
+
* in JS), not user-perceived characters. Characters outside the BMP — including
|
|
1149
|
+
* many emoji — count as 2.
|
|
1150
|
+
*
|
|
1151
|
+
* @example
|
|
1152
|
+
* { type: JsonSchemaType.String, minLength: 5 }
|
|
1153
|
+
*
|
|
1154
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.3.2
|
|
1155
|
+
*/
|
|
1156
|
+
minLength?: number;
|
|
1157
|
+
/**
|
|
1158
|
+
* ECMA-262 regular expression the string value must match.
|
|
1159
|
+
*
|
|
1160
|
+
* **No implicit anchors** — the pattern matches if it can be found anywhere in
|
|
1161
|
+
* the string. To require a full match, anchor explicitly with `^` and `$`.
|
|
1162
|
+
* Common pitfall: `'[0-9]'` means "contains a digit", not "consists of digits".
|
|
1163
|
+
*
|
|
1164
|
+
* @example
|
|
1165
|
+
* // Contains at least one digit.
|
|
1166
|
+
* { type: JsonSchemaType.String, pattern: '[0-9]' }
|
|
1167
|
+
*
|
|
1168
|
+
* @example
|
|
1169
|
+
* // Capitalised word from start to end.
|
|
1170
|
+
* { type: JsonSchemaType.String, pattern: '^[A-Z][a-z]+$' }
|
|
1171
|
+
*
|
|
1172
|
+
* @see https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6.3.3
|
|
1173
|
+
*/
|
|
1174
|
+
pattern?: string;
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Discriminated union of every supported JSON Schema variant. Narrow with the `type` keyword to access type-specific fields.
|
|
1178
|
+
*
|
|
1179
|
+
* @example
|
|
1180
|
+
* const schema: JsonSchema = { type: JsonSchemaType.String, minLength: 1 };
|
|
1181
|
+
*
|
|
1182
|
+
* @example
|
|
1183
|
+
* const schema: JsonSchema = { type: JsonSchemaType.Object, properties: { id: { type: JsonSchemaType.Number } } };
|
|
1184
|
+
*/
|
|
1185
|
+
export type JsonSchema<Config extends SchemaRendererConfig = any> = JsonSchemaAny<Config> | JsonSchemaArray<Config> | JsonSchemaBoolean<Config> | JsonSchemaNumber<Config> | JsonSchemaObject<Config> | JsonSchemaString<Config>;
|
|
1186
|
+
export {};
|