@digigov/form 2.0.0-264e5fff → 2.0.0-290ada95
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/Field/ErrorGroup.d.ts +2 -2
- package/Field/ErrorGroup.js +53 -0
- package/Field/FieldBase.d.ts +1 -1
- package/Field/FieldBase.js +77 -0
- package/Field/FieldBaseContainer.d.ts +1 -1
- package/Field/FieldBaseContainer.js +43 -0
- package/Field/FieldConditional.d.ts +1 -1
- package/Field/FieldConditional.js +45 -0
- package/Field/index.d.ts +1 -1
- package/Field/index.js +69 -107
- package/Field/types.d.ts +3 -3
- package/Field/types.js +0 -0
- package/Field/utils/evaluateFieldWithConditions.d.ts +1 -1
- package/Field/utils/evaluateFieldWithConditions.js +19 -0
- package/Field/utils/resolveField.d.ts +2 -2
- package/Field/utils/resolveField.js +32 -0
- package/Field/utils/useField.d.ts +1 -1
- package/Field/utils/useField.js +47 -0
- package/FieldArray/BaseFieldArray.d.ts +1 -1
- package/FieldArray/BaseFieldArray.js +46 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js +13 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js +117 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js +32 -57
- package/FieldArray/FormDialog/ArrayEditModal.d.ts +1 -1
- package/FieldArray/FormDialog/ArrayEditModal.js +138 -0
- package/FieldArray/FormDialog/index.d.ts +1 -1
- package/FieldArray/FormDialog/index.js +142 -177
- package/FieldArray/index.d.ts +2 -2
- package/FieldArray/index.js +59 -86
- package/FieldObject/index.d.ts +2 -2
- package/FieldObject/index.js +52 -77
- package/Fieldset/FieldsetWithContext.js +27 -0
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +18 -30
- package/Fieldset/types.js +0 -0
- package/FormBuilder/index.d.ts +2 -2
- package/FormBuilder/index.js +226 -254
- package/FormContext.d.ts +1 -1
- package/FormContext.js +7 -0
- package/MultiplicityField/add-objects.d.ts +1 -1
- package/MultiplicityField/add-objects.js +107 -0
- package/MultiplicityField/index.d.ts +1 -1
- package/MultiplicityField/index.js +81 -119
- package/MultiplicityField/types.d.ts +1 -1
- package/MultiplicityField/types.js +0 -0
- package/Questions/Questions.d.ts +1 -1
- package/Questions/Questions.js +48 -0
- package/Questions/QuestionsContext.d.ts +1 -1
- package/Questions/QuestionsContext.js +10 -0
- package/Questions/Step/ReviewStep.js +32 -0
- package/Questions/Step/Step.d.ts +1 -1
- package/Questions/Step/Step.js +39 -0
- package/Questions/Step/StepArrayReview.d.ts +1 -1
- package/Questions/Step/StepArrayReview.js +35 -0
- package/Questions/Step/StepContext.d.ts +1 -1
- package/Questions/Step/StepContext.js +28 -0
- package/Questions/Step/StepDescription.js +18 -0
- package/Questions/Step/StepForm.d.ts +2 -2
- package/Questions/Step/StepForm.js +29 -0
- package/Questions/Step/StepQuote.js +5 -0
- package/Questions/Step/StepTitle.js +25 -0
- package/Questions/Step/getAddMoreFields.d.ts +2 -2
- package/Questions/Step/getAddMoreFields.js +24 -0
- package/Questions/Step/index.d.ts +11 -11
- package/Questions/Step/index.js +13 -16
- package/Questions/Step/types.d.ts +1 -1
- package/Questions/Step/types.js +0 -0
- package/Questions/getNextStep.d.ts +1 -1
- package/Questions/getNextStep.js +13 -0
- package/Questions/index.d.ts +2 -2
- package/Questions/index.js +4 -7
- package/Questions/types.d.ts +1 -1
- package/Questions/types.js +0 -0
- package/hooks/useFieldFocusManager.js +83 -0
- package/hooks/utils.js +60 -0
- package/index.d.ts +5 -5
- package/index.js +8 -13
- package/inputs/AutoCompleteInput/index.d.ts +2 -2
- package/inputs/AutoCompleteInput/index.js +38 -60
- package/inputs/Checkboxes/index.d.ts +2 -2
- package/inputs/Checkboxes/index.js +43 -76
- package/inputs/DateInput/index.d.ts +1 -1
- package/inputs/DateInput/index.js +123 -147
- package/inputs/DateTimeInput/index.d.ts +1 -1
- package/inputs/DateTimeInput/index.js +177 -207
- package/inputs/FileInput/index.d.ts +1 -1
- package/inputs/FileInput/index.js +54 -70
- package/inputs/ImageInput/index.d.ts +1 -1
- package/inputs/ImageInput/index.js +74 -74
- package/inputs/Input/index.d.ts +1 -1
- package/inputs/Input/index.js +60 -73
- package/inputs/Label/index.d.ts +1 -1
- package/inputs/Label/index.js +13 -16
- package/inputs/OtpInput/index.js +116 -145
- package/inputs/Radio/index.d.ts +2 -2
- package/inputs/Radio/index.js +70 -103
- package/inputs/Select/index.d.ts +2 -2
- package/inputs/Select/index.js +23 -32
- package/inputs/index.d.ts +9 -9
- package/inputs/index.js +10 -21
- package/inputs/registry.d.ts +1 -1
- package/inputs/registry.js +80 -0
- package/internal.d.ts +5 -5
- package/internal.js +6 -0
- package/lazy.d.ts +97 -0
- package/lazy.js +163 -0
- package/package.json +8 -8
- package/registry.d.ts +82 -0
- package/registry.js +170 -0
- package/src/Field/ErrorGroup.tsx +1 -1
- package/src/FormBuilder/doc.mdx +1 -1
- package/src/inputs/AutoCompleteInput/doc.mdx +2 -2
- package/src/inputs/Checkboxes/doc.mdx +3 -3
- package/src/inputs/DateInput/doc.mdx +1 -1
- package/src/inputs/DateTimeInput/doc.mdx +1 -1
- package/src/inputs/FileInput/doc.mdx +1 -1
- package/src/inputs/ImageInput/doc.mdx +3 -3
- package/src/inputs/Input/doc.mdx +10 -10
- package/src/inputs/Label/doc.mdx +1 -1
- package/src/inputs/OtpInput/doc.mdx +1 -1
- package/src/inputs/Radio/doc.mdx +3 -3
- package/src/inputs/Select/doc.mdx +1 -1
- package/{lazy/index.js → src/lazy.ts} +0 -25
- package/types.d.ts +4 -4
- package/types.js +1 -0
- package/utils.js +56 -0
- package/validators/index.d.ts +2 -2
- package/validators/index.js +112 -159
- package/validators/types.js +0 -0
- package/validators/utils/afm.js +19 -0
- package/validators/utils/amka.js +27 -0
- package/validators/utils/date.d.ts +2 -2
- package/validators/utils/date.js +95 -0
- package/validators/utils/datetime.d.ts +2 -2
- package/validators/utils/datetime.js +121 -0
- package/validators/utils/email.js +10 -0
- package/validators/utils/file.d.ts +2 -2
- package/validators/utils/file.js +31 -0
- package/validators/utils/iban.d.ts +2 -2
- package/validators/utils/iban.js +104 -0
- package/validators/utils/image.d.ts +2 -2
- package/validators/utils/image.js +65 -0
- package/validators/utils/index.d.ts +14 -14
- package/validators/utils/index.js +58 -96
- package/validators/utils/int.d.ts +1 -1
- package/validators/utils/int.js +13 -0
- package/validators/utils/number.d.ts +1 -1
- package/validators/utils/number.js +12 -0
- package/validators/utils/otp.d.ts +2 -2
- package/validators/utils/otp.js +21 -0
- package/validators/utils/phone.d.ts +2 -2
- package/validators/utils/phone.js +198 -0
- package/validators/utils/postal_code.d.ts +2 -2
- package/validators/utils/postal_code.js +18 -0
- package/validators/utils/text_limit.d.ts +2 -2
- package/validators/utils/text_limit.js +34 -0
- package/validators/utils/uuid4.js +14 -0
- package/Field/ErrorGroup/index.js +0 -48
- package/Field/ErrorGroup/package.json +0 -6
- package/Field/ErrorGroup.js.map +0 -7
- package/Field/FieldBase/index.js +0 -122
- package/Field/FieldBase/package.json +0 -6
- package/Field/FieldBase.js.map +0 -7
- package/Field/FieldBaseContainer/index.js +0 -52
- package/Field/FieldBaseContainer/package.json +0 -6
- package/Field/FieldBaseContainer.js.map +0 -7
- package/Field/FieldConditional/index.js +0 -89
- package/Field/FieldConditional/package.json +0 -6
- package/Field/FieldConditional.js.map +0 -7
- package/Field/index.js.map +0 -7
- package/Field/package.json +0 -6
- package/Field/types/index.js +0 -1
- package/Field/types/package.json +0 -6
- package/Field/types.js.map +0 -7
- package/Field/utils/evaluateFieldWithConditions/index.js +0 -26
- package/Field/utils/evaluateFieldWithConditions/package.json +0 -6
- package/Field/utils/evaluateFieldWithConditions.js.map +0 -7
- package/Field/utils/resolveField/index.js +0 -35
- package/Field/utils/resolveField/package.json +0 -6
- package/Field/utils/resolveField.js.map +0 -7
- package/Field/utils/useField/index.js +0 -66
- package/Field/utils/useField/package.json +0 -6
- package/Field/utils/useField.js.map +0 -7
- package/FieldArray/BaseFieldArray/index.js +0 -76
- package/FieldArray/BaseFieldArray/package.json +0 -6
- package/FieldArray/BaseFieldArray.js.map +0 -7
- package/FieldArray/FieldArray.stories.d.ts +0 -11
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +0 -23
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/package.json +0 -6
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +0 -7
- package/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.d.ts +0 -13
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +0 -184
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/package.json +0 -6
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +0 -7
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +0 -11
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/package.json +0 -6
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +0 -7
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/index.js.map +0 -7
- package/FieldArray/FormDialog/ArrayDisplay/package.json +0 -6
- package/FieldArray/FormDialog/ArrayEditModal/index.js +0 -158
- package/FieldArray/FormDialog/ArrayEditModal/package.json +0 -6
- package/FieldArray/FormDialog/ArrayEditModal.js.map +0 -7
- package/FieldArray/FormDialog/index.js.map +0 -7
- package/FieldArray/FormDialog/package.json +0 -6
- package/FieldArray/__stories__/CardsWithError.d.ts +0 -15
- package/FieldArray/__stories__/Default.d.ts +0 -2
- package/FieldArray/__stories__/WithExactLength.d.ts +0 -2
- package/FieldArray/__stories__/WithModal.d.ts +0 -2
- package/FieldArray/index.js.map +0 -7
- package/FieldArray/package.json +0 -6
- package/FieldObject/index.js.map +0 -7
- package/FieldObject/package.json +0 -6
- package/Fieldset/FieldsetWithContext/index.js +0 -31
- package/Fieldset/FieldsetWithContext/package.json +0 -6
- package/Fieldset/FieldsetWithContext.js.map +0 -7
- package/Fieldset/index.js.map +0 -7
- package/Fieldset/package.json +0 -6
- package/Fieldset/types/index.js +0 -1
- package/Fieldset/types/package.json +0 -6
- package/Fieldset/types.js.map +0 -7
- package/Form.stories.d.ts +0 -4
- package/FormBuilder/FormBuilder.stories.d.ts +0 -12
- package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +0 -3
- package/FormBuilder/__stories__/Default.d.ts +0 -3
- package/FormBuilder/__stories__/ErrorGrouping.d.ts +0 -3
- package/FormBuilder/index.js.map +0 -7
- package/FormBuilder/package.json +0 -6
- package/FormContext/index.js +0 -13
- package/FormContext/package.json +0 -6
- package/FormContext.js.map +0 -7
- package/MultiplicityField/MultiplicityField.stories.d.ts +0 -15
- package/MultiplicityField/__stories__/Default.d.ts +0 -2
- package/MultiplicityField/__stories__/PreviewDisplay.d.ts +0 -2
- package/MultiplicityField/__stories__/WithExactLength.d.ts +0 -2
- package/MultiplicityField/__stories__/WithMaxLength.d.ts +0 -2
- package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +0 -2
- package/MultiplicityField/__stories__/WithMinLength.d.ts +0 -2
- package/MultiplicityField/add-objects/index.js +0 -146
- package/MultiplicityField/add-objects/package.json +0 -6
- package/MultiplicityField/add-objects.js.map +0 -7
- package/MultiplicityField/index.js.map +0 -7
- package/MultiplicityField/package.json +0 -6
- package/MultiplicityField/types/index.js +0 -1
- package/MultiplicityField/types/package.json +0 -6
- package/MultiplicityField/types.js.map +0 -7
- package/Questions/Questions/index.js +0 -67
- package/Questions/Questions/package.json +0 -6
- package/Questions/Questions.js.map +0 -7
- package/Questions/Questions.stories.d.ts +0 -10
- package/Questions/QuestionsContext/index.js +0 -11
- package/Questions/QuestionsContext/package.json +0 -6
- package/Questions/QuestionsContext.js.map +0 -7
- package/Questions/Step/ReviewStep/index.js +0 -38
- package/Questions/Step/ReviewStep/package.json +0 -6
- package/Questions/Step/ReviewStep.js.map +0 -7
- package/Questions/Step/Step/index.js +0 -54
- package/Questions/Step/Step/package.json +0 -6
- package/Questions/Step/Step.js.map +0 -7
- package/Questions/Step/StepArrayReview/index.js +0 -42
- package/Questions/Step/StepArrayReview/package.json +0 -6
- package/Questions/Step/StepArrayReview.js.map +0 -7
- package/Questions/Step/StepContext/index.js +0 -23
- package/Questions/Step/StepContext/package.json +0 -6
- package/Questions/Step/StepContext.js.map +0 -7
- package/Questions/Step/StepDescription/index.js +0 -24
- package/Questions/Step/StepDescription/package.json +0 -6
- package/Questions/Step/StepDescription.js.map +0 -7
- package/Questions/Step/StepForm/index.js +0 -34
- package/Questions/Step/StepForm/package.json +0 -6
- package/Questions/Step/StepForm.js.map +0 -7
- package/Questions/Step/StepQuote/index.js +0 -11
- package/Questions/Step/StepQuote/package.json +0 -6
- package/Questions/Step/StepQuote.js.map +0 -7
- package/Questions/Step/StepTitle/index.js +0 -44
- package/Questions/Step/StepTitle/package.json +0 -6
- package/Questions/Step/StepTitle.js.map +0 -7
- package/Questions/Step/getAddMoreFields/index.js +0 -29
- package/Questions/Step/getAddMoreFields/package.json +0 -6
- package/Questions/Step/getAddMoreFields.js.map +0 -7
- package/Questions/Step/index.js.map +0 -7
- package/Questions/Step/package.json +0 -6
- package/Questions/Step/types/index.js +0 -1
- package/Questions/Step/types/package.json +0 -6
- package/Questions/Step/types.js.map +0 -7
- package/Questions/__stories__/Default.d.ts +0 -3
- package/Questions/getNextStep/index.js +0 -22
- package/Questions/getNextStep/package.json +0 -6
- package/Questions/getNextStep.js.map +0 -7
- package/Questions/index.js.map +0 -7
- package/Questions/package.json +0 -6
- package/Questions/types/index.js +0 -1
- package/Questions/types/package.json +0 -6
- package/Questions/types.js.map +0 -7
- package/cjs/Field/ErrorGroup/index.js +0 -82
- package/cjs/Field/ErrorGroup.js.map +0 -7
- package/cjs/Field/FieldBase/index.js +0 -155
- package/cjs/Field/FieldBase.js.map +0 -7
- package/cjs/Field/FieldBaseContainer/index.js +0 -85
- package/cjs/Field/FieldBaseContainer.js.map +0 -7
- package/cjs/Field/FieldConditional/index.js +0 -122
- package/cjs/Field/FieldConditional.js.map +0 -7
- package/cjs/Field/index.js +0 -143
- package/cjs/Field/index.js.map +0 -7
- package/cjs/Field/types/index.js +0 -16
- package/cjs/Field/types.js.map +0 -7
- package/cjs/Field/utils/evaluateFieldWithConditions/index.js +0 -49
- package/cjs/Field/utils/evaluateFieldWithConditions.js.map +0 -7
- package/cjs/Field/utils/resolveField/index.js +0 -55
- package/cjs/Field/utils/resolveField.js.map +0 -7
- package/cjs/Field/utils/useField/index.js +0 -89
- package/cjs/Field/utils/useField.js.map +0 -7
- package/cjs/FieldArray/BaseFieldArray/index.js +0 -109
- package/cjs/FieldArray/BaseFieldArray.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +0 -56
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +0 -209
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +0 -44
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js +0 -90
- package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayEditModal/index.js +0 -186
- package/cjs/FieldArray/FormDialog/ArrayEditModal.js.map +0 -7
- package/cjs/FieldArray/FormDialog/index.js +0 -261
- package/cjs/FieldArray/FormDialog/index.js.map +0 -7
- package/cjs/FieldArray/index.js +0 -126
- package/cjs/FieldArray/index.js.map +0 -7
- package/cjs/FieldObject/index.js +0 -113
- package/cjs/FieldObject/index.js.map +0 -7
- package/cjs/Fieldset/FieldsetWithContext/index.js +0 -59
- package/cjs/Fieldset/FieldsetWithContext.js.map +0 -7
- package/cjs/Fieldset/index.js +0 -66
- package/cjs/Fieldset/index.js.map +0 -7
- package/cjs/Fieldset/types/index.js +0 -16
- package/cjs/Fieldset/types.js.map +0 -7
- package/cjs/FormBuilder/index.js +0 -303
- package/cjs/FormBuilder/index.js.map +0 -7
- package/cjs/FormContext/index.js +0 -37
- package/cjs/FormContext.js.map +0 -7
- package/cjs/MultiplicityField/add-objects/index.js +0 -179
- package/cjs/MultiplicityField/add-objects.js.map +0 -7
- package/cjs/MultiplicityField/index.js +0 -153
- package/cjs/MultiplicityField/index.js.map +0 -7
- package/cjs/MultiplicityField/types/index.js +0 -16
- package/cjs/MultiplicityField/types.js.map +0 -7
- package/cjs/Questions/Questions/index.js +0 -100
- package/cjs/Questions/Questions.js.map +0 -7
- package/cjs/Questions/QuestionsContext/index.js +0 -34
- package/cjs/Questions/QuestionsContext.js.map +0 -7
- package/cjs/Questions/Step/ReviewStep/index.js +0 -65
- package/cjs/Questions/Step/ReviewStep.js.map +0 -7
- package/cjs/Questions/Step/Step/index.js +0 -87
- package/cjs/Questions/Step/Step.js.map +0 -7
- package/cjs/Questions/Step/StepArrayReview/index.js +0 -67
- package/cjs/Questions/Step/StepArrayReview.js.map +0 -7
- package/cjs/Questions/Step/StepContext/index.js +0 -46
- package/cjs/Questions/Step/StepContext.js.map +0 -7
- package/cjs/Questions/Step/StepDescription/index.js +0 -58
- package/cjs/Questions/Step/StepDescription.js.map +0 -7
- package/cjs/Questions/Step/StepForm/index.js +0 -67
- package/cjs/Questions/Step/StepForm.js.map +0 -7
- package/cjs/Questions/Step/StepQuote/index.js +0 -44
- package/cjs/Questions/Step/StepQuote.js.map +0 -7
- package/cjs/Questions/Step/StepTitle/index.js +0 -76
- package/cjs/Questions/Step/StepTitle.js.map +0 -7
- package/cjs/Questions/Step/getAddMoreFields/index.js +0 -52
- package/cjs/Questions/Step/getAddMoreFields.js.map +0 -7
- package/cjs/Questions/Step/index.js +0 -59
- package/cjs/Questions/Step/index.js.map +0 -7
- package/cjs/Questions/Step/types/index.js +0 -16
- package/cjs/Questions/Step/types.js.map +0 -7
- package/cjs/Questions/getNextStep/index.js +0 -45
- package/cjs/Questions/getNextStep.js.map +0 -7
- package/cjs/Questions/index.js +0 -31
- package/cjs/Questions/index.js.map +0 -7
- package/cjs/Questions/types/index.js +0 -16
- package/cjs/Questions/types.js.map +0 -7
- package/cjs/hooks/useFieldFocusManager/index.js +0 -135
- package/cjs/hooks/useFieldFocusManager.js.map +0 -7
- package/cjs/hooks/utils/index.js +0 -98
- package/cjs/hooks/utils.js.map +0 -7
- package/cjs/index.js +0 -49
- package/cjs/index.js.map +0 -7
- package/cjs/inputs/AutoCompleteInput/index.js +0 -98
- package/cjs/inputs/AutoCompleteInput/index.js.map +0 -7
- package/cjs/inputs/Checkboxes/index.js +0 -112
- package/cjs/inputs/Checkboxes/index.js.map +0 -7
- package/cjs/inputs/DateInput/index.js +0 -188
- package/cjs/inputs/DateInput/index.js.map +0 -7
- package/cjs/inputs/DateTimeInput/index.js +0 -250
- package/cjs/inputs/DateTimeInput/index.js.map +0 -7
- package/cjs/inputs/FileInput/index.js +0 -110
- package/cjs/inputs/FileInput/index.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/logo.d/index.js +0 -1
- package/cjs/inputs/ImageInput/__stories__/logo.d.js.map +0 -7
- package/cjs/inputs/ImageInput/index.js +0 -130
- package/cjs/inputs/ImageInput/index.js.map +0 -7
- package/cjs/inputs/Input/index.js +0 -115
- package/cjs/inputs/Input/index.js.map +0 -7
- package/cjs/inputs/Label/index.js +0 -50
- package/cjs/inputs/Label/index.js.map +0 -7
- package/cjs/inputs/OtpInput/index.js +0 -186
- package/cjs/inputs/OtpInput/index.js.map +0 -7
- package/cjs/inputs/Radio/index.js +0 -136
- package/cjs/inputs/Radio/index.js.map +0 -7
- package/cjs/inputs/Select/index.js +0 -63
- package/cjs/inputs/Select/index.js.map +0 -7
- package/cjs/inputs/index.js +0 -62
- package/cjs/inputs/index.js.map +0 -7
- package/cjs/inputs/registry/index.js +0 -121
- package/cjs/inputs/registry.js.map +0 -7
- package/cjs/internal/index.js +0 -38
- package/cjs/internal.js.map +0 -7
- package/cjs/lazy/index.js +0 -114
- package/cjs/lazy.js.map +0 -7
- package/cjs/registry/index.js +0 -209
- package/cjs/registry.js.map +0 -7
- package/cjs/types/index.js +0 -22
- package/cjs/types.js.map +0 -7
- package/cjs/utils/index.js +0 -106
- package/cjs/utils.js.map +0 -7
- package/cjs/validators/index.js +0 -179
- package/cjs/validators/index.js.map +0 -7
- package/cjs/validators/types/index.js +0 -16
- package/cjs/validators/types.js.map +0 -7
- package/cjs/validators/utils/afm/index.js +0 -55
- package/cjs/validators/utils/afm.js.map +0 -7
- package/cjs/validators/utils/amka/index.js +0 -60
- package/cjs/validators/utils/amka.js.map +0 -7
- package/cjs/validators/utils/date/index.js +0 -161
- package/cjs/validators/utils/date.js.map +0 -7
- package/cjs/validators/utils/datetime/index.js +0 -245
- package/cjs/validators/utils/datetime.js.map +0 -7
- package/cjs/validators/utils/email/index.js +0 -39
- package/cjs/validators/utils/email.js.map +0 -7
- package/cjs/validators/utils/file/index.js +0 -61
- package/cjs/validators/utils/file.js.map +0 -7
- package/cjs/validators/utils/iban/index.js +0 -142
- package/cjs/validators/utils/iban.js.map +0 -7
- package/cjs/validators/utils/image/index.js +0 -102
- package/cjs/validators/utils/image.js.map +0 -7
- package/cjs/validators/utils/index.js +0 -152
- package/cjs/validators/utils/index.js.map +0 -7
- package/cjs/validators/utils/int/index.js +0 -48
- package/cjs/validators/utils/int.js.map +0 -7
- package/cjs/validators/utils/number/index.js +0 -44
- package/cjs/validators/utils/number.js.map +0 -7
- package/cjs/validators/utils/otp/index.js +0 -54
- package/cjs/validators/utils/otp.js.map +0 -7
- package/cjs/validators/utils/phone/index.js +0 -198
- package/cjs/validators/utils/phone.js.map +0 -7
- package/cjs/validators/utils/postal_code/index.js +0 -54
- package/cjs/validators/utils/postal_code.js.map +0 -7
- package/cjs/validators/utils/text_limit/index.js +0 -69
- package/cjs/validators/utils/text_limit.js.map +0 -7
- package/cjs/validators/utils/uuid4/index.js +0 -46
- package/cjs/validators/utils/uuid4.js.map +0 -7
- package/hooks/__tests__/utils.spec.d.ts +0 -1
- package/hooks/useFieldFocusManager/index.js +0 -116
- package/hooks/useFieldFocusManager/package.json +0 -6
- package/hooks/useFieldFocusManager.js.map +0 -7
- package/hooks/utils/index.js +0 -73
- package/hooks/utils/package.json +0 -6
- package/hooks/utils.js.map +0 -7
- package/index.js.map +0 -7
- package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +0 -11
- package/inputs/AutoCompleteInput/__stories__/Default.d.ts +0 -3
- package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +0 -3
- package/inputs/AutoCompleteInput/index.js.map +0 -7
- package/inputs/AutoCompleteInput/package.json +0 -6
- package/inputs/Checkboxes/Checkboxes.stories.d.ts +0 -12
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +0 -3
- package/inputs/Checkboxes/__stories__/Default.d.ts +0 -3
- package/inputs/Checkboxes/__stories__/WithDivider.d.ts +0 -3
- package/inputs/Checkboxes/index.js.map +0 -7
- package/inputs/Checkboxes/package.json +0 -6
- package/inputs/DateInput/DateInput.stories.d.ts +0 -14
- package/inputs/DateInput/__stories__/Default.d.ts +0 -3
- package/inputs/DateInput/__stories__/WithDefaultValue.d.ts +0 -3
- package/inputs/DateInput/__stories__/WithInitialValue.d.ts +0 -3
- package/inputs/DateInput/__stories__/WithWrongDefaultValue.d.ts +0 -3
- package/inputs/DateInput/__stories__/WithWrongInitialValue.d.ts +0 -3
- package/inputs/DateInput/index.js.map +0 -7
- package/inputs/DateInput/package.json +0 -6
- package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +0 -14
- package/inputs/DateTimeInput/__stories__/Default.d.ts +0 -3
- package/inputs/DateTimeInput/__stories__/WithDefaultValue.d.ts +0 -3
- package/inputs/DateTimeInput/__stories__/WithInitialValue.d.ts +0 -3
- package/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.d.ts +0 -3
- package/inputs/DateTimeInput/__stories__/WithWrongInitialValue.d.ts +0 -3
- package/inputs/DateTimeInput/index.js.map +0 -7
- package/inputs/DateTimeInput/package.json +0 -6
- package/inputs/FileInput/FileInput.stories.d.ts +0 -11
- package/inputs/FileInput/__stories__/Default.d.ts +0 -3
- package/inputs/FileInput/__stories__/WithBorderAndLink.d.ts +0 -3
- package/inputs/FileInput/index.js.map +0 -7
- package/inputs/FileInput/package.json +0 -6
- package/inputs/ImageInput/ImageInput.stories.d.ts +0 -13
- package/inputs/ImageInput/__stories__/Default.d.ts +0 -3
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +0 -3
- package/inputs/ImageInput/__stories__/WithInitialValues.d.ts +0 -3
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +0 -3
- package/inputs/ImageInput/__stories__/logo.d/index.js +0 -1
- package/inputs/ImageInput/__stories__/logo.d/package.json +0 -6
- package/inputs/ImageInput/__stories__/logo.d.js.map +0 -7
- package/inputs/ImageInput/index.js.map +0 -7
- package/inputs/ImageInput/package.json +0 -6
- package/inputs/Input/Input.stories.d.ts +0 -23
- package/inputs/Input/__stories__/AFM.d.ts +0 -3
- package/inputs/Input/__stories__/AMKA.d.ts +0 -3
- package/inputs/Input/__stories__/Boolean.d.ts +0 -3
- package/inputs/Input/__stories__/Email.d.ts +0 -3
- package/inputs/Input/__stories__/IBAN.d.ts +0 -3
- package/inputs/Input/__stories__/Integer.d.ts +0 -3
- package/inputs/Input/__stories__/LandlineNumber.d.ts +0 -3
- package/inputs/Input/__stories__/MobilePhone.d.ts +0 -3
- package/inputs/Input/__stories__/PhoneNumber.d.ts +0 -3
- package/inputs/Input/__stories__/PostalCode.d.ts +0 -3
- package/inputs/Input/__stories__/Rate.d.ts +0 -3
- package/inputs/Input/__stories__/String.d.ts +0 -3
- package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +0 -3
- package/inputs/Input/__stories__/TextWithLimit.d.ts +0 -3
- package/inputs/Input/index.js.map +0 -7
- package/inputs/Input/package.json +0 -6
- package/inputs/Label/Label.stories.d.ts +0 -10
- package/inputs/Label/__stories__/Default.d.ts +0 -3
- package/inputs/Label/index.js.map +0 -7
- package/inputs/Label/package.json +0 -6
- package/inputs/OtpInput/OtpInput.stories.d.ts +0 -10
- package/inputs/OtpInput/__stories__/Default.d.ts +0 -3
- package/inputs/OtpInput/index.js.map +0 -7
- package/inputs/OtpInput/package.json +0 -6
- package/inputs/Radio/Radio.stories.d.ts +0 -12
- package/inputs/Radio/__stories__/Conditional.d.ts +0 -3
- package/inputs/Radio/__stories__/Default.d.ts +0 -3
- package/inputs/Radio/__stories__/WithDivider.d.ts +0 -3
- package/inputs/Radio/index.js.map +0 -7
- package/inputs/Radio/package.json +0 -6
- package/inputs/Select/Select.stories.d.ts +0 -10
- package/inputs/Select/__stories__/Default.d.ts +0 -3
- package/inputs/Select/index.js.map +0 -7
- package/inputs/Select/package.json +0 -6
- package/inputs/index.js.map +0 -7
- package/inputs/package.json +0 -6
- package/inputs/registry/index.js +0 -86
- package/inputs/registry/package.json +0 -6
- package/inputs/registry.js.map +0 -7
- package/internal/index.js +0 -10
- package/internal/package.json +0 -6
- package/internal.js.map +0 -7
- package/lazy/package.json +0 -6
- package/registry/index.js +0 -179
- package/registry/package.json +0 -6
- package/src/lazy.js +0 -81
- package/types/index.js +0 -2
- package/types/package.json +0 -6
- package/types.js.map +0 -7
- package/utils/index.js +0 -82
- package/utils/package.json +0 -6
- package/utils.js.map +0 -7
- package/validators/index.js.map +0 -7
- package/validators/package.json +0 -6
- package/validators/types/index.js +0 -1
- package/validators/types/package.json +0 -6
- package/validators/types.js.map +0 -7
- package/validators/utils/afm/index.js +0 -31
- package/validators/utils/afm/package.json +0 -6
- package/validators/utils/afm.js.map +0 -7
- package/validators/utils/amka/index.js +0 -36
- package/validators/utils/amka/package.json +0 -6
- package/validators/utils/amka.js.map +0 -7
- package/validators/utils/date/index.js +0 -126
- package/validators/utils/date/package.json +0 -6
- package/validators/utils/date.js.map +0 -7
- package/validators/utils/datetime/index.js +0 -210
- package/validators/utils/datetime/package.json +0 -6
- package/validators/utils/datetime.js.map +0 -7
- package/validators/utils/email/index.js +0 -16
- package/validators/utils/email/package.json +0 -6
- package/validators/utils/email.js.map +0 -7
- package/validators/utils/file/index.js +0 -38
- package/validators/utils/file/package.json +0 -6
- package/validators/utils/file.js.map +0 -7
- package/validators/utils/iban/index.js +0 -118
- package/validators/utils/iban/package.json +0 -6
- package/validators/utils/iban.js.map +0 -7
- package/validators/utils/image/index.js +0 -79
- package/validators/utils/image/package.json +0 -6
- package/validators/utils/image.js.map +0 -7
- package/validators/utils/index.js.map +0 -7
- package/validators/utils/int/index.js +0 -24
- package/validators/utils/int/package.json +0 -6
- package/validators/utils/int.js.map +0 -7
- package/validators/utils/number/index.js +0 -20
- package/validators/utils/number/package.json +0 -6
- package/validators/utils/number.js.map +0 -7
- package/validators/utils/otp/index.js +0 -30
- package/validators/utils/otp/package.json +0 -6
- package/validators/utils/otp.js.map +0 -7
- package/validators/utils/package.json +0 -6
- package/validators/utils/phone/index.js +0 -172
- package/validators/utils/phone/package.json +0 -6
- package/validators/utils/phone.js.map +0 -7
- package/validators/utils/postal_code/index.js +0 -30
- package/validators/utils/postal_code/package.json +0 -6
- package/validators/utils/postal_code.js.map +0 -7
- package/validators/utils/text_limit/index.js +0 -45
- package/validators/utils/text_limit/package.json +0 -6
- package/validators/utils/text_limit.js.map +0 -7
- package/validators/utils/uuid4/index.js +0 -22
- package/validators/utils/uuid4/package.json +0 -6
- package/validators/utils/uuid4.js.map +0 -7
- package/validators/validators.spec.d.ts +0 -1
- package/src/{registry.js → registry.ts} +6 -6
package/src/inputs/Radio/doc.mdx
CHANGED
|
@@ -10,14 +10,14 @@ Radios are used to let a user select one option of a limited number of choices.
|
|
|
10
10
|
|
|
11
11
|
### Default
|
|
12
12
|
|
|
13
|
-
<code src="@digigov/form/inputs/Radio/__stories__/Default.tsx" />
|
|
13
|
+
<code src="@digigov/form/src/inputs/Radio/__stories__/Default.tsx" />
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
### Conditional
|
|
17
17
|
|
|
18
|
-
<code src="@digigov/form/inputs/Radio/__stories__/Conditional.tsx" />
|
|
18
|
+
<code src="@digigov/form/src/inputs/Radio/__stories__/Conditional.tsx" />
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
### With divider
|
|
22
22
|
|
|
23
|
-
<code src="@digigov/form/inputs/Radio/__stories__/WithDivider.tsx" />
|
|
23
|
+
<code src="@digigov/form/src/inputs/Radio/__stories__/WithDivider.tsx" />
|
|
@@ -42,38 +42,13 @@ export default {
|
|
|
42
42
|
'Input': lazy(() => import('@digigov/form/inputs/Input').then((module) => ({ default: module['Input'] }))),
|
|
43
43
|
'Radio': lazy(() => import('@digigov/form/inputs').then((module) => ({ default: module['Radio'] }))),
|
|
44
44
|
'Select': lazy(() => import('@digigov/form/inputs/Select').then((module) => ({ default: module['Select'] }))),
|
|
45
|
-
'FIELD_COMPONENTS': lazy(() => import('@digigov/form/inputs/registry').then((module) => ({ default: module['FIELD_COMPONENTS'] }))),
|
|
46
|
-
'ALTERNATIVE_COMPONENTS': lazy(() => import('@digigov/form/inputs/registry').then((module) => ({ default: module['ALTERNATIVE_COMPONENTS'] }))),
|
|
47
|
-
'CONTROLLED_FIELD_COMPONENTS': lazy(() => import('@digigov/form/inputs/registry').then((module) => ({ default: module['CONTROLLED_FIELD_COMPONENTS'] }))),
|
|
48
45
|
'ArrayEditModal': lazy(() => import('@digigov/form/FieldArray/FormDialog/ArrayEditModal').then((module) => ({ default: module['ArrayEditModal'] }))),
|
|
49
46
|
'FormDialog': lazy(() => import('@digigov/form/FieldArray/FormDialog').then((module) => ({ default: module['FormDialog'] }))),
|
|
50
47
|
'AutoCompleteInput': lazy(() => import('@digigov/form/inputs/AutoCompleteInput').then((module) => ({ default: module['AutoCompleteInput'] }))),
|
|
51
48
|
'DateTimeInput': lazy(() => import('@digigov/form/inputs/DateTimeInput').then((module) => ({ default: module['DateTimeInput'] }))),
|
|
52
49
|
'Image': lazy(() => import('@digigov/form/inputs/ImageInput').then((module) => ({ default: module['Image'] }))),
|
|
53
|
-
'RE_DIGIT': lazy(() => import('@digigov/form/inputs/OtpInput').then((module) => ({ default: module['RE_DIGIT'] }))),
|
|
54
|
-
'REMOVE_SPACES': lazy(() => import('@digigov/form/inputs/OtpInput').then((module) => ({ default: module['REMOVE_SPACES'] }))),
|
|
55
50
|
'RadioButtonsGroup': lazy(() => import('@digigov/form/inputs/Radio').then((module) => ({ default: module['RadioButtonsGroup'] }))),
|
|
56
51
|
'ControlledRadioButtonsGroup': lazy(() => import('@digigov/form/inputs/Radio').then((module) => ({ default: module['ControlledRadioButtonsGroup'] }))),
|
|
57
|
-
'AFM_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['AFM_VALIDATOR'] }))),
|
|
58
|
-
'AMKA_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['AMKA_VALIDATOR'] }))),
|
|
59
|
-
'LATER_THAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['LATER_THAN_VALIDATOR'] }))),
|
|
60
|
-
'EARLIER_THAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['EARLIER_THAN_VALIDATOR'] }))),
|
|
61
|
-
'DATE_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['DATE_VALIDATOR'] }))),
|
|
62
|
-
'LATER_THAN_DATETIME_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['LATER_THAN_DATETIME_VALIDATOR'] }))),
|
|
63
|
-
'EARLIER_THAN_DATETIME_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['EARLIER_THAN_DATETIME_VALIDATOR'] }))),
|
|
64
|
-
'DATETIME_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['DATETIME_VALIDATOR'] }))),
|
|
65
|
-
'EMAIL_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/email').then((module) => ({ default: module['EMAIL_VALIDATOR'] }))),
|
|
66
|
-
'FILE_MAX_SIZE_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['FILE_MAX_SIZE_VALIDATOR'] }))),
|
|
67
|
-
'IBAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['IBAN_VALIDATOR'] }))),
|
|
68
|
-
'IMAGE_DIMENSION_VALIDATOR': lazy(() => import('@digigov/form/validators/utils').then((module) => ({ default: module['IMAGE_DIMENSION_VALIDATOR'] }))),
|
|
69
|
-
'OTP_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/otp').then((module) => ({ default: module['OTP_VALIDATOR'] }))),
|
|
70
|
-
'MOBILE_PHONE_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/phone').then((module) => ({ default: module['MOBILE_PHONE_VALIDATOR'] }))),
|
|
71
|
-
'PHONE_NUMBER_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/phone').then((module) => ({ default: module['PHONE_NUMBER_VALIDATOR'] }))),
|
|
72
|
-
'POSTALCODE_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/postal_code').then((module) => ({ default: module['POSTALCODE_VALIDATOR'] }))),
|
|
73
|
-
'UUID4_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/uuid4').then((module) => ({ default: module['UUID4_VALIDATOR'] }))),
|
|
74
|
-
'TEXT_LIMIT_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/text_limit').then((module) => ({ default: module['TEXT_LIMIT_VALIDATOR'] }))),
|
|
75
|
-
'INT_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/int').then((module) => ({ default: module['INT_VALIDATOR'] }))),
|
|
76
|
-
'NUMBER_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/number').then((module) => ({ default: module['NUMBER_VALIDATOR'] }))),
|
|
77
52
|
'ArrayContainerDisplay': lazy(() => import('@digigov/form/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay').then((module) => ({ default: module['ArrayContainerDisplay'] }))),
|
|
78
53
|
'ArrayItemDisplay': lazy(() => import('@digigov/form/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay').then((module) => ({ default: module['ArrayItemDisplay'] }))),
|
|
79
54
|
'ArrayItemHeader': lazy(() => import('@digigov/form/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader').then((module) => ({ default: module['ArrayItemHeader'] }))),
|
package/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { UseFormReturn, UseFormProps, ErrorOption } from 'react-hook-form';
|
|
2
|
-
import type { FieldLabelProps, FieldSpec, FormData } from '
|
|
3
|
-
import type { FieldComponentRegistry } from '
|
|
4
|
-
import type { ValidatorSchema } from '
|
|
5
|
-
export * from '
|
|
2
|
+
import type { FieldLabelProps, FieldSpec, FormData } from './Field/types.js';
|
|
3
|
+
import type { FieldComponentRegistry } from './inputs/registry.js';
|
|
4
|
+
import type { ValidatorSchema } from './validators/types.js';
|
|
5
|
+
export * from './Field/types.js';
|
|
6
6
|
export interface FieldError {
|
|
7
7
|
message: string;
|
|
8
8
|
}
|
package/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Field/types.js";
|
package/utils.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { validateFieldsNatively } from "@hookform/resolvers";
|
|
2
|
+
import { appendErrors } from "react-hook-form";
|
|
3
|
+
const parseErrorSchema = (error, validateAllFieldCriteria)=>(error.inner || []).reduce((previous, error)=>{
|
|
4
|
+
error.path = error.path?.replace(/\[([0-9]+)\]/g, '.$1');
|
|
5
|
+
if (!previous[error.path]) previous[error.path] = {
|
|
6
|
+
message: error.message,
|
|
7
|
+
type: error.type
|
|
8
|
+
};
|
|
9
|
+
if (validateAllFieldCriteria) {
|
|
10
|
+
const types = previous[error.path].types;
|
|
11
|
+
const messages = types && types[error.type];
|
|
12
|
+
previous[error.path] = appendErrors(error.path, validateAllFieldCriteria, previous, error.type, messages ? [].concat(messages, error.message) : error.message);
|
|
13
|
+
}
|
|
14
|
+
return previous;
|
|
15
|
+
}, {});
|
|
16
|
+
function isPlainObject(obj) {
|
|
17
|
+
return 'object' == typeof obj && null !== obj && '[object Object]' === Object.prototype.toString.call(obj);
|
|
18
|
+
}
|
|
19
|
+
function flattenObject(obj, prefix = '') {
|
|
20
|
+
return Object.keys(obj).reduce((acc, key)=>{
|
|
21
|
+
const prefixedKey = prefix ? `${prefix}.${key}` : key;
|
|
22
|
+
if (isPlainObject(obj[key])) Object.assign(acc, flattenObject(obj[key], prefixedKey));
|
|
23
|
+
else acc[prefixedKey] = obj[key];
|
|
24
|
+
return acc;
|
|
25
|
+
}, {});
|
|
26
|
+
}
|
|
27
|
+
const yupResolver = (schema, schemaOptions = {}, resolverOptions = {})=>async (values, context, options)=>{
|
|
28
|
+
try {
|
|
29
|
+
if (schemaOptions.context && 'development' === process.env.NODE_ENV) console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
|
|
30
|
+
const result = await schema['sync' === resolverOptions.mode ? 'validateSync' : 'validate'](flattenObject(values), Object.assign({
|
|
31
|
+
abortEarly: false
|
|
32
|
+
}, schemaOptions, {
|
|
33
|
+
context
|
|
34
|
+
}));
|
|
35
|
+
if (options.shouldUseNativeValidation) validateFieldsNatively({}, options);
|
|
36
|
+
return {
|
|
37
|
+
values: resolverOptions.rawValues ? values : result,
|
|
38
|
+
errors: {}
|
|
39
|
+
};
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (!e.inner) throw e;
|
|
42
|
+
return {
|
|
43
|
+
values: {},
|
|
44
|
+
errors: parseErrorSchema(e, !options.shouldUseNativeValidation && 'all' === options.criteriaMode),
|
|
45
|
+
options
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function omit(obj, keys) {
|
|
50
|
+
const result = {
|
|
51
|
+
...obj
|
|
52
|
+
};
|
|
53
|
+
for (const key of keys)delete result[key];
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
export { omit, yupResolver };
|
package/validators/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { MutableRefObject } from 'react';
|
|
2
2
|
import type { AnyObjectSchema } from 'yup';
|
|
3
3
|
import type Lazy from 'yup/lib/Lazy';
|
|
4
|
-
import type { FieldSpec } from '
|
|
5
|
-
import type { ValidatorSchema } from '
|
|
4
|
+
import type { FieldSpec } from '../types.js';
|
|
5
|
+
import type { ValidatorSchema } from './types.js';
|
|
6
6
|
export declare const getYUPTypeMap: (validatorRegistry?: Record<string, any>) => Record<string, any>;
|
|
7
7
|
export interface MutableRefObjectProps {
|
|
8
8
|
}
|
package/validators/index.js
CHANGED
|
@@ -1,164 +1,117 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
field.extra.min = 1;
|
|
69
|
-
}
|
|
70
|
-
let arrayValidator = yup.array().nullable().of(yupTypeMap[field.extra.of.type](field.extra.of));
|
|
71
|
-
if (field.extra.length)
|
|
72
|
-
arrayValidator = arrayValidator.length(field.extra.length, {
|
|
73
|
-
key: "form.error.array.length",
|
|
74
|
-
context: {
|
|
75
|
-
length: field.extra.length
|
|
2
|
+
import { array, boolean as external_yup_boolean, mixed, number, string } from "yup";
|
|
3
|
+
import { AFM_VALIDATOR, AMKA_VALIDATOR, DATETIME_VALIDATOR, DATE_VALIDATOR, EARLIER_THAN_DATETIME_VALIDATOR, EARLIER_THAN_VALIDATOR, FILE_MAX_SIZE_VALIDATOR, IBAN_VALIDATOR, IMAGE_DIMENSION_VALIDATOR, LATER_THAN_DATETIME_VALIDATOR, LATER_THAN_VALIDATOR, MOBILE_PHONE_VALIDATOR, OTP_VALIDATOR, PHONE_NUMBER_VALIDATOR, POSTALCODE_VALIDATOR, TEXT_LIMIT_VALIDATOR, UUID4_VALIDATOR, getYupObjectShape } from "./utils/index.js";
|
|
4
|
+
import { EMAIL_VALIDATOR } from "./utils/email.js";
|
|
5
|
+
import { INT_VALIDATOR } from "./utils/int.js";
|
|
6
|
+
import { NUMBER_VALIDATOR } from "./utils/number.js";
|
|
7
|
+
const getYUPTypeMap = (validatorRegistry)=>{
|
|
8
|
+
const yupTypeMap = {
|
|
9
|
+
file: (field)=>mixed().transform((value)=>{
|
|
10
|
+
if (!value || 0 === value.length) return null;
|
|
11
|
+
return value;
|
|
12
|
+
}).nullable().test(FILE_MAX_SIZE_VALIDATOR(field)),
|
|
13
|
+
string: (field)=>{
|
|
14
|
+
if (field.trim) return string().trim();
|
|
15
|
+
return string();
|
|
16
|
+
},
|
|
17
|
+
boolean: ()=>external_yup_boolean().nullable().transform((value)=>{
|
|
18
|
+
if ('' === value || 'string' == typeof value) return null;
|
|
19
|
+
if ('boolean' == typeof value) return value;
|
|
20
|
+
if (0 === value || 1 === value) return Boolean(value);
|
|
21
|
+
return value;
|
|
22
|
+
}),
|
|
23
|
+
object: (field)=>getYupObjectShape(field.extra.fields, yupTypeMap),
|
|
24
|
+
rate: (field)=>{
|
|
25
|
+
const min = field?.min ? field.min : 0;
|
|
26
|
+
const max = field?.max ? field.max : 100;
|
|
27
|
+
return number().transform((v, o)=>'' === o ? null : v).nullable().notRequired().integer({
|
|
28
|
+
key: 'form.error.positive_integer_number'
|
|
29
|
+
}).min(min, {
|
|
30
|
+
key: 'form.error.rate.rate_percent',
|
|
31
|
+
context: {
|
|
32
|
+
min: min,
|
|
33
|
+
max: max
|
|
34
|
+
}
|
|
35
|
+
}).max(max, {
|
|
36
|
+
key: 'form.error.rate.rate_percent',
|
|
37
|
+
context: {
|
|
38
|
+
min: min,
|
|
39
|
+
max: max
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
array: (field)=>{
|
|
44
|
+
if ('object' == typeof field.extra.of) {
|
|
45
|
+
if (field.required) field.extra.min = 1;
|
|
46
|
+
let arrayValidator = array().nullable().of(yupTypeMap[field.extra.of.type](field.extra.of));
|
|
47
|
+
if (field.extra.length) arrayValidator = arrayValidator.length(field.extra.length, {
|
|
48
|
+
key: 'form.error.array.length',
|
|
49
|
+
context: {
|
|
50
|
+
length: field.extra.length
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (field.extra.min) arrayValidator = arrayValidator.min(field.extra.min, {
|
|
54
|
+
key: 'form.error.array.min',
|
|
55
|
+
context: {
|
|
56
|
+
min: field.extra.min,
|
|
57
|
+
max: field.extra.max || void 0
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (field.extra.max) arrayValidator = arrayValidator.max(field.extra.max, {
|
|
61
|
+
key: 'form.error.array.max',
|
|
62
|
+
context: {
|
|
63
|
+
min: field.extra.min || void 0,
|
|
64
|
+
max: field.extra.max
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return arrayValidator;
|
|
76
68
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
image: (field) => {
|
|
117
|
-
return yup.mixed().transform((value) => {
|
|
118
|
-
if (!value.length || value.length === 0) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
return value;
|
|
122
|
-
}).nullable().test(FILE_MAX_SIZE_VALIDATOR(field)).test(IMAGE_DIMENSION_VALIDATOR(field));
|
|
123
|
-
},
|
|
124
|
-
postal_code: (field) => field.trim ? yup.string().trim().test(POSTALCODE_VALIDATOR(field)) : yup.string().test(POSTALCODE_VALIDATOR(field)),
|
|
125
|
-
mobile_phone: (field) => field.trim ? yup.string().trim().test(MOBILE_PHONE_VALIDATOR) : yup.string().test(MOBILE_PHONE_VALIDATOR),
|
|
126
|
-
phone_number: (field) => field.trim ? yup.string().trim().test(PHONE_NUMBER_VALIDATOR(field)) : yup.string().test(PHONE_NUMBER_VALIDATOR(field)),
|
|
127
|
-
"choice:multiple": () => yup.array().of(yup.string()).nullable(),
|
|
128
|
-
"choice:single": () => yup.string().nullable(),
|
|
129
|
-
date: (field) => {
|
|
130
|
-
let schema = yup.string().nullable();
|
|
131
|
-
if (field?.extra?.min) {
|
|
132
|
-
schema = schema.test(LATER_THAN_VALIDATOR(field));
|
|
133
|
-
}
|
|
134
|
-
if (field?.extra?.max) {
|
|
135
|
-
schema = schema.test(EARLIER_THAN_VALIDATOR(field));
|
|
136
|
-
} else {
|
|
137
|
-
schema = schema.test(DATE_VALIDATOR);
|
|
138
|
-
}
|
|
139
|
-
return schema;
|
|
140
|
-
},
|
|
141
|
-
datetime: (field) => {
|
|
142
|
-
if (field?.extra?.min) {
|
|
143
|
-
return yup.string().test(LATER_THAN_DATETIME_VALIDATOR(field));
|
|
144
|
-
}
|
|
145
|
-
if (field?.extra?.max) {
|
|
146
|
-
return yup.string().test(EARLIER_THAN_DATETIME_VALIDATOR(field));
|
|
147
|
-
}
|
|
148
|
-
return yup.string().test(DATETIME_VALIDATOR);
|
|
149
|
-
},
|
|
150
|
-
...validatorRegistry
|
|
151
|
-
};
|
|
152
|
-
return yupTypeMap;
|
|
69
|
+
if ('string' == typeof field.extra.of) return array().of(yupTypeMap[field.extra.of]());
|
|
70
|
+
return array().of(string());
|
|
71
|
+
},
|
|
72
|
+
number: ()=>mixed().transform((_, val)=>'' !== val ? Number(val) : void 0).test(NUMBER_VALIDATOR()),
|
|
73
|
+
int: ()=>mixed().transform((_, val)=>'' !== val ? Number(val) : void 0).test(NUMBER_VALIDATOR()).test(INT_VALIDATOR()),
|
|
74
|
+
email: (field)=>field.trim ? string().trim().test(EMAIL_VALIDATOR) : string().test(EMAIL_VALIDATOR),
|
|
75
|
+
afm: (field)=>field.trim ? string().trim().test(AFM_VALIDATOR) : string().test(AFM_VALIDATOR),
|
|
76
|
+
amka: (field)=>field.trim ? string().trim().test(AMKA_VALIDATOR) : string().test(AMKA_VALIDATOR),
|
|
77
|
+
uuid4: (field)=>field.trim ? string().trim().test(UUID4_VALIDATOR) : string().test(UUID4_VALIDATOR),
|
|
78
|
+
iban: (field)=>field.trim ? string().trim().test(IBAN_VALIDATOR(field)) : string().trim().test(IBAN_VALIDATOR(field)),
|
|
79
|
+
otp: (field)=>string().trim().test(OTP_VALIDATOR(field)),
|
|
80
|
+
text: (field)=>{
|
|
81
|
+
if (field?.extra?.limit?.max || !!field?.extra?.limit?.min) return field.trim ? string().trim().test(TEXT_LIMIT_VALIDATOR(field)) : string().test(TEXT_LIMIT_VALIDATOR(field));
|
|
82
|
+
return field.trim ? string().trim() : string();
|
|
83
|
+
},
|
|
84
|
+
image: (field)=>mixed().transform((value)=>{
|
|
85
|
+
if (!value.length || 0 === value.length) return null;
|
|
86
|
+
return value;
|
|
87
|
+
}).nullable().test(FILE_MAX_SIZE_VALIDATOR(field)).test(IMAGE_DIMENSION_VALIDATOR(field)),
|
|
88
|
+
postal_code: (field)=>field.trim ? string().trim().test(POSTALCODE_VALIDATOR(field)) : string().test(POSTALCODE_VALIDATOR(field)),
|
|
89
|
+
mobile_phone: (field)=>field.trim ? string().trim().test(MOBILE_PHONE_VALIDATOR) : string().test(MOBILE_PHONE_VALIDATOR),
|
|
90
|
+
phone_number: (field)=>field.trim ? string().trim().test(PHONE_NUMBER_VALIDATOR(field)) : string().test(PHONE_NUMBER_VALIDATOR(field)),
|
|
91
|
+
'choice:multiple': ()=>array().of(string()).nullable(),
|
|
92
|
+
'choice:single': ()=>string().nullable(),
|
|
93
|
+
date: (field)=>{
|
|
94
|
+
let schema = string().nullable();
|
|
95
|
+
if (field?.extra?.min) schema = schema.test(LATER_THAN_VALIDATOR(field));
|
|
96
|
+
schema = field?.extra?.max ? schema.test(EARLIER_THAN_VALIDATOR(field)) : schema.test(DATE_VALIDATOR);
|
|
97
|
+
return schema;
|
|
98
|
+
},
|
|
99
|
+
datetime: (field)=>{
|
|
100
|
+
if (field?.extra?.min) return string().test(LATER_THAN_DATETIME_VALIDATOR(field));
|
|
101
|
+
if (field?.extra?.max) return string().test(EARLIER_THAN_DATETIME_VALIDATOR(field));
|
|
102
|
+
return string().test(DATETIME_VALIDATOR);
|
|
103
|
+
},
|
|
104
|
+
...validatorRegistry
|
|
105
|
+
};
|
|
106
|
+
return yupTypeMap;
|
|
153
107
|
};
|
|
154
108
|
function useValidationSchema(fields, validatorRegistry) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
109
|
+
return useMemo(()=>{
|
|
110
|
+
const yupTypeMap = getYUPTypeMap(validatorRegistry);
|
|
111
|
+
return getYupObjectShape(fields, yupTypeMap, validatorRegistry);
|
|
112
|
+
}, [
|
|
113
|
+
fields,
|
|
114
|
+
validatorRegistry
|
|
115
|
+
]);
|
|
159
116
|
}
|
|
160
|
-
export {
|
|
161
|
-
getYUPTypeMap,
|
|
162
|
-
useValidationSchema
|
|
163
|
-
};
|
|
164
|
-
//# sourceMappingURL=index.js.map
|
|
117
|
+
export { getYUPTypeMap, useValidationSchema };
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function validateAFM(afm) {
|
|
2
|
+
if (9 !== afm.length) return false;
|
|
3
|
+
if (!/^\d+$/.test(afm)) return false;
|
|
4
|
+
if (afm === '0'.repeat(9)) return false;
|
|
5
|
+
const sum = afm.substring(0, 8).split('').reduce((s, v, i)=>s + (parseInt(v) << 8 - i), 0);
|
|
6
|
+
const calc = sum % 11;
|
|
7
|
+
const d9 = parseInt(afm[8]);
|
|
8
|
+
const valid = calc % 10 === d9;
|
|
9
|
+
return valid;
|
|
10
|
+
}
|
|
11
|
+
const AFM_VALIDATOR = {
|
|
12
|
+
name: 'afm-validator',
|
|
13
|
+
message: 'form.error.afm',
|
|
14
|
+
test: (value)=>{
|
|
15
|
+
if (value) return validateAFM(value);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export { AFM_VALIDATOR, validateAFM };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function digitSum(number) {
|
|
2
|
+
const sum = number > 9 ? 1 : 0;
|
|
3
|
+
return sum + number % 10;
|
|
4
|
+
}
|
|
5
|
+
function validateAMKA(amka) {
|
|
6
|
+
amka = String(amka);
|
|
7
|
+
const checkDigitIndex = amka.length - 1;
|
|
8
|
+
let sum = 0;
|
|
9
|
+
amka.substring(0, checkDigitIndex).split('').reverse().forEach(function(value, index) {
|
|
10
|
+
const weight = (index + 1) % 2 + 1;
|
|
11
|
+
sum += digitSum(parseInt(value, 10) * weight);
|
|
12
|
+
});
|
|
13
|
+
const sumMod10 = sum % 10;
|
|
14
|
+
if (0 === sumMod10) return '0' === amka.substring(checkDigitIndex);
|
|
15
|
+
return amka.substring(checkDigitIndex) === 10 - sumMod10 + '';
|
|
16
|
+
}
|
|
17
|
+
const AMKA_VALIDATOR = {
|
|
18
|
+
name: 'amka-validator',
|
|
19
|
+
message: 'form.error.amka',
|
|
20
|
+
test: (value)=>{
|
|
21
|
+
if (!value) return true;
|
|
22
|
+
const AMKA_REGEX = /^[0-9]{11}$/;
|
|
23
|
+
if (!AMKA_REGEX.test(value) || '00000000000' === value) return false;
|
|
24
|
+
return validateAMKA(value);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export { AMKA_VALIDATOR, validateAMKA };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FieldSpec } from '
|
|
2
|
-
import type { ValidatorSchema } from '
|
|
1
|
+
import type { FieldSpec } from '../../types.js';
|
|
2
|
+
import type { ValidatorSchema } from '../types.js';
|
|
3
3
|
export declare const LATER_THAN_VALIDATOR: (field: FieldSpec) => ValidatorSchema;
|
|
4
4
|
export declare const EARLIER_THAN_VALIDATOR: (field: FieldSpec) => ValidatorSchema;
|
|
5
5
|
export declare const DATE_VALIDATOR: {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import customParseFormat from "dayjs/plugin/customParseFormat.js";
|
|
3
|
+
dayjs.extend(customParseFormat);
|
|
4
|
+
const VALID_DATE_FORMATS = [
|
|
5
|
+
'DD/MM/YYYY'
|
|
6
|
+
];
|
|
7
|
+
const DATE_CACHE = {};
|
|
8
|
+
const onlyNumbersRegex = /^\d+$/;
|
|
9
|
+
const getDate = (v)=>DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);
|
|
10
|
+
const getDaysInMonth = (month, year)=>dayjs(`${year}-${month}-01`).daysInMonth();
|
|
11
|
+
const checkPartialDate = (value)=>{
|
|
12
|
+
const [day, month, year] = value.split('/');
|
|
13
|
+
if (day && !month && !year) return 'form.error.date.invalid_month_year';
|
|
14
|
+
if (!day && month && !year) return 'form.error.date.invalid_day_year';
|
|
15
|
+
if (!day && !month && year) return 'form.error.date.invalid_day_month';
|
|
16
|
+
if (day && month && !year) return 'form.error.date.invalid_year';
|
|
17
|
+
if (day && !month && year) return 'form.error.date.invalid_month';
|
|
18
|
+
if (!day && month && year) return 'form.error.date.invalid_day';
|
|
19
|
+
if (day && month) {
|
|
20
|
+
const dayNum = parseInt(day);
|
|
21
|
+
const monthNum = parseInt(month);
|
|
22
|
+
const validYear = onlyNumbersRegex.test(year) ? year : void 0;
|
|
23
|
+
if (!validYear || year.length < 4) return 'form.error.date.invalid';
|
|
24
|
+
const yearNum = parseInt(validYear);
|
|
25
|
+
const maxDay = getDaysInMonth(monthNum, yearNum);
|
|
26
|
+
if (dayNum < 1 || dayNum > maxDay) return {
|
|
27
|
+
key: 'form.error.date.invalid_day_range',
|
|
28
|
+
context: {
|
|
29
|
+
maxDay: maxDay
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
if (monthNum < 1 || monthNum > 12) return 'form.error.datetime.invalid_month_range';
|
|
33
|
+
}
|
|
34
|
+
return 'form.error.date.invalid';
|
|
35
|
+
};
|
|
36
|
+
const LATER_THAN_VALIDATOR = (field)=>{
|
|
37
|
+
let minDate;
|
|
38
|
+
const params = field.extra || {};
|
|
39
|
+
if ('now' === params.min) {
|
|
40
|
+
const today = new Date();
|
|
41
|
+
minDate = new Date(today);
|
|
42
|
+
} else minDate = getDate(params.min).toDate();
|
|
43
|
+
const minPreviousDate = new Date(minDate);
|
|
44
|
+
minPreviousDate.setDate(minDate.getDate() - 1);
|
|
45
|
+
return {
|
|
46
|
+
name: 'later-than',
|
|
47
|
+
message: {
|
|
48
|
+
key: 'form.error.date.later_than',
|
|
49
|
+
context: {
|
|
50
|
+
minDate: minPreviousDate.toLocaleDateString()
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
test: function(value) {
|
|
54
|
+
if (!value) return true;
|
|
55
|
+
const date = getDate(value);
|
|
56
|
+
const isValid = +date.toDate() > +minDate;
|
|
57
|
+
return isValid;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const EARLIER_THAN_VALIDATOR = (field)=>{
|
|
62
|
+
let maxDate;
|
|
63
|
+
const params = field.extra || {};
|
|
64
|
+
if ('now' === params.max) {
|
|
65
|
+
const today = new Date();
|
|
66
|
+
maxDate = new Date(today);
|
|
67
|
+
} else maxDate = getDate(params.max).toDate();
|
|
68
|
+
const maxNextDate = new Date(maxDate);
|
|
69
|
+
maxNextDate.setDate(maxDate.getDate() + 1);
|
|
70
|
+
return {
|
|
71
|
+
name: 'earlier-than',
|
|
72
|
+
message: {
|
|
73
|
+
key: 'form.error.date.earlier_than',
|
|
74
|
+
context: {
|
|
75
|
+
maxDate: maxNextDate.toLocaleDateString()
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
test: function(value) {
|
|
79
|
+
if (!value) return true;
|
|
80
|
+
const date = getDate(value);
|
|
81
|
+
const isValid = +date.toDate() < +maxDate;
|
|
82
|
+
return isValid;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const DATE_VALIDATOR = {
|
|
87
|
+
name: 'date-validator',
|
|
88
|
+
message: (v)=>checkPartialDate(v.value),
|
|
89
|
+
test: function(value) {
|
|
90
|
+
if (!value) return true;
|
|
91
|
+
const date = getDate(value);
|
|
92
|
+
return date.isValid();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export { DATE_VALIDATOR, EARLIER_THAN_VALIDATOR, LATER_THAN_VALIDATOR };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FieldSpec } from '
|
|
2
|
-
import type { ValidatorSchema } from '
|
|
1
|
+
import type { FieldSpec } from '../../types.js';
|
|
2
|
+
import type { ValidatorSchema } from '../types.js';
|
|
3
3
|
export declare const LATER_THAN_DATETIME_VALIDATOR: (field: FieldSpec) => ValidatorSchema;
|
|
4
4
|
export declare const EARLIER_THAN_DATETIME_VALIDATOR: (field: FieldSpec) => ValidatorSchema;
|
|
5
5
|
export declare const DATETIME_VALIDATOR: {
|