@digigov/form 2.0.0-13876dba → 2.0.0-16fbe090
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 +4 -4
- package/Field/ErrorGroup.js +53 -0
- package/Field/FieldBase.d.ts +1 -1
- package/Field/FieldBase.js +77 -0
- package/Field/FieldBaseContainer.d.ts +2 -2
- 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 +70 -112
- package/Field/types.d.ts +22 -12
- package/Field/types.js +0 -0
- package/Field/utils/evaluateFieldWithConditions.d.ts +2 -2
- package/Field/utils/evaluateFieldWithConditions.js +19 -0
- package/Field/utils/resolveField.d.ts +3 -0
- 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 +5 -0
- package/FieldArray/BaseFieldArray.js +46 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.d.ts +9 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js +13 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.d.ts +26 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js +117 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.d.ts +5 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.d.ts +15 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js +32 -0
- package/FieldArray/FormDialog/ArrayEditModal.d.ts +24 -0
- package/FieldArray/FormDialog/ArrayEditModal.js +138 -0
- package/FieldArray/FormDialog/index.d.ts +19 -0
- package/FieldArray/FormDialog/index.js +191 -271
- package/FieldArray/index.d.ts +5 -2
- package/FieldArray/index.js +62 -106
- package/FieldObject/index.d.ts +7 -4
- package/FieldObject/index.js +51 -72
- package/Fieldset/FieldsetWithContext.js +27 -0
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +18 -30
- package/Fieldset/types.d.ts +2 -2
- package/Fieldset/types.js +0 -0
- package/FormBuilder/index.d.ts +2 -2
- package/FormBuilder/index.js +233 -231
- package/FormContext.d.ts +3 -2
- package/FormContext.js +7 -0
- package/MultiplicityField/add-objects.d.ts +2 -2
- package/MultiplicityField/add-objects.js +107 -0
- package/MultiplicityField/index.d.ts +2 -2
- package/MultiplicityField/index.js +81 -116
- package/MultiplicityField/types.d.ts +3 -2
- 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.d.ts +1 -1
- 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.d.ts +1 -1
- package/Questions/Step/StepQuote.js +5 -0
- package/Questions/Step/StepTitle.d.ts +1 -1
- 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.d.ts +25 -0
- package/hooks/useFieldFocusManager.js +83 -0
- package/hooks/utils.d.ts +18 -0
- package/hooks/utils.js +60 -0
- package/index.d.ts +5 -5
- package/index.js +8 -13
- package/inputs/AutoCompleteInput/index.d.ts +3 -3
- package/inputs/AutoCompleteInput/index.js +38 -62
- package/inputs/Checkboxes/index.d.ts +5 -3
- package/inputs/Checkboxes/index.js +50 -78
- package/inputs/DateInput/index.d.ts +2 -5
- package/inputs/DateInput/index.js +125 -117
- package/inputs/DateTimeInput/index.d.ts +2 -5
- package/inputs/DateTimeInput/index.js +179 -170
- package/inputs/FileInput/index.d.ts +12 -5
- package/inputs/FileInput/index.js +58 -59
- package/inputs/ImageInput/index.d.ts +10 -2
- package/inputs/ImageInput/index.js +84 -53
- package/inputs/Input/index.d.ts +5 -2
- package/inputs/Input/index.js +60 -69
- package/inputs/Label/index.d.ts +1 -1
- package/inputs/Label/index.js +13 -16
- package/inputs/OtpInput/index.d.ts +1 -5
- package/inputs/OtpInput/index.js +117 -141
- package/inputs/Radio/index.d.ts +6 -4
- package/inputs/Radio/index.js +71 -102
- package/inputs/Select/index.d.ts +6 -3
- package/inputs/Select/index.js +23 -31
- package/inputs/index.d.ts +9 -9
- package/inputs/index.js +10 -21
- package/{Field/utils/index.d.ts → inputs/registry.d.ts} +2 -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 +12 -12
- package/registry.d.ts +82 -0
- package/registry.js +170 -0
- package/src/Field/ErrorGroup.tsx +4 -4
- package/src/Field/FieldBase.tsx +9 -4
- package/src/Field/FieldBaseContainer.tsx +69 -48
- package/src/Field/FieldConditional.tsx +5 -1
- package/src/Field/index.tsx +27 -37
- package/src/Field/types.tsx +24 -14
- package/src/Field/utils/evaluateFieldWithConditions.ts +5 -2
- package/src/Field/utils/resolveField.ts +58 -0
- package/src/Field/utils/useField.ts +12 -2
- package/src/FieldArray/BaseFieldArray.tsx +97 -0
- package/src/FieldArray/FieldArray.stories.js +1 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.tsx +45 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.js +14 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.tsx +337 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.tsx +15 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.tsx +88 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.tsx +93 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.tsx +79 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.tsx +75 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.tsx +93 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.tsx +88 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/index.test.tsx +44 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/index.tsx +67 -0
- package/src/FieldArray/FormDialog/ArrayEditModal.tsx +241 -0
- package/src/FieldArray/FormDialog/index.tsx +302 -0
- package/src/FieldArray/__stories__/CardsWithError.tsx +124 -0
- package/src/FieldArray/__stories__/WithModal.tsx +3 -2
- package/src/FieldArray/__tests__/fieldset-multiplicity.spec.tsx +271 -0
- package/src/FieldArray/__tests__/multiplicity-attachment.spec.tsx +280 -0
- package/src/FieldArray/__tests__/multiplicity-optional.spec.tsx +232 -0
- package/src/FieldArray/__tests__/multiplicity-required.spec.tsx +170 -0
- package/src/FieldArray/__tests__/nested-fieldset-multiplicity.spec.tsx +627 -0
- package/src/FieldArray/__tests__/preference-multiple-choice.spec.tsx +222 -0
- package/src/FieldArray/index.spec.tsx +355 -0
- package/src/FieldArray/index.test.tsx +4 -0
- package/src/FieldArray/index.tsx +49 -73
- package/src/FieldObject/index.tsx +36 -31
- package/src/Fieldset/FieldsetWithContext.tsx +1 -1
- package/src/Fieldset/index.tsx +1 -1
- package/src/Fieldset/types.tsx +2 -2
- package/src/FormBuilder/doc.mdx +1 -1
- package/src/FormBuilder/index.tsx +197 -146
- package/src/FormBuilder/scenarios.test.tsx +806 -9
- package/src/FormContext.tsx +7 -2
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +1 -3
- package/src/MultiplicityField/add-objects.tsx +14 -21
- package/src/MultiplicityField/index.tsx +6 -2
- package/src/MultiplicityField/types.ts +6 -2
- package/src/Questions/Questions.tsx +2 -2
- package/src/Questions/QuestionsContext.tsx +1 -1
- package/src/Questions/Step/Step.tsx +1 -1
- package/src/Questions/Step/StepArrayReview.tsx +2 -2
- package/src/Questions/Step/StepContext.tsx +1 -1
- package/src/Questions/Step/StepDescription.tsx +2 -1
- package/src/Questions/Step/StepForm.tsx +2 -2
- package/src/Questions/Step/StepQuote.tsx +2 -1
- package/src/Questions/Step/StepTitle.tsx +2 -1
- package/src/Questions/Step/getAddMoreFields.tsx +2 -2
- package/src/Questions/Step/types.tsx +1 -1
- package/src/Questions/getNextStep.tsx +1 -1
- package/src/Questions/types.tsx +1 -1
- package/src/hooks/__tests__/useFieldFocusManager.spec.tsx +1079 -0
- package/src/hooks/__tests__/utils.spec.ts +568 -0
- package/src/hooks/useFieldFocusManager.ts +162 -0
- package/src/hooks/utils.ts +122 -0
- package/src/inputs/AutoCompleteInput/doc.mdx +2 -2
- package/src/inputs/AutoCompleteInput/index.tsx +4 -6
- package/src/inputs/Checkboxes/doc.mdx +3 -3
- package/src/inputs/Checkboxes/index.tsx +98 -91
- package/src/inputs/DateInput/DateInput.stories.js +4 -0
- package/src/inputs/DateInput/__stories__/WithDefaultValue.tsx +26 -0
- package/src/inputs/DateInput/__stories__/WithInitialValue.tsx +28 -0
- package/src/inputs/DateInput/__stories__/WithWrongDefaultValue.tsx +26 -0
- package/src/inputs/DateInput/__stories__/WithWrongInitialValue.tsx +28 -0
- package/src/inputs/DateInput/doc.mdx +1 -1
- package/src/inputs/DateInput/index.test.tsx +16 -0
- package/src/inputs/DateInput/index.tsx +65 -20
- package/src/inputs/DateTimeInput/DateTimeInput.stories.js +9 -6
- package/src/inputs/DateTimeInput/__stories__/WithDefaultValue.tsx +26 -0
- package/src/inputs/DateTimeInput/__stories__/WithInitialValue.tsx +28 -0
- package/src/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.tsx +26 -0
- package/src/inputs/DateTimeInput/__stories__/WithWrongInitialValue.tsx +28 -0
- package/src/inputs/DateTimeInput/doc.mdx +1 -1
- package/src/inputs/DateTimeInput/index.test.tsx +16 -0
- package/src/inputs/DateTimeInput/index.tsx +92 -40
- package/src/inputs/FileInput/FileInput.stories.js +1 -0
- package/src/inputs/FileInput/__stories__/WithBorderAndLink.tsx +34 -0
- package/src/inputs/FileInput/doc.mdx +1 -1
- package/src/inputs/FileInput/index.test.tsx +4 -0
- package/src/inputs/FileInput/index.tsx +83 -47
- package/src/inputs/ImageInput/ImageInput.stories.js +2 -1
- package/src/inputs/ImageInput/__stories__/MaxSize.tsx +2 -1
- package/src/inputs/ImageInput/__stories__/WithInitialValues.tsx +45 -0
- package/src/inputs/ImageInput/__stories__/logo.d.ts +4 -0
- package/src/inputs/ImageInput/__stories__/logo.png +0 -0
- package/src/inputs/ImageInput/doc.mdx +3 -3
- package/src/inputs/ImageInput/index.test.tsx +21 -17
- package/src/inputs/ImageInput/index.tsx +102 -50
- package/src/inputs/Input/Input.stories.js +3 -0
- package/src/inputs/Input/__stories__/AMKA.tsx +23 -0
- package/src/inputs/Input/__stories__/Email.tsx +23 -0
- package/src/inputs/Input/__stories__/Rate.tsx +25 -0
- package/src/inputs/Input/doc.mdx +10 -10
- package/src/inputs/Input/index.test.tsx +12 -0
- package/src/inputs/Input/index.tsx +19 -10
- package/src/inputs/Label/doc.mdx +1 -1
- package/src/inputs/Label/index.tsx +1 -1
- package/src/inputs/OtpInput/doc.mdx +1 -1
- package/src/inputs/OtpInput/index.tsx +43 -34
- package/src/inputs/Radio/doc.mdx +3 -3
- package/src/inputs/Radio/index.tsx +33 -22
- package/src/inputs/Select/doc.mdx +1 -1
- package/src/inputs/Select/index.tsx +12 -7
- package/src/{Field/utils/index.ts → inputs/registry.ts} +5 -1
- package/{lazy/index.js → src/lazy.ts} +8 -29
- package/{registry/index.js → src/registry.ts} +33 -19
- package/src/types.tsx +14 -5
- package/src/utils.ts +41 -8
- package/src/validators/index.ts +50 -17
- package/src/validators/types.ts +1 -1
- package/src/validators/utils/amka.ts +39 -0
- package/src/validators/utils/date.ts +30 -6
- package/src/validators/utils/datetime.ts +123 -31
- package/src/validators/utils/email.ts +11 -0
- package/src/validators/utils/file.ts +35 -21
- package/src/validators/utils/iban.ts +2 -2
- package/src/validators/utils/image.ts +2 -2
- package/src/validators/utils/index.ts +13 -6
- package/src/validators/utils/int.ts +1 -1
- package/src/validators/utils/number.ts +1 -1
- package/src/validators/utils/otp.ts +2 -2
- package/src/validators/utils/phone.ts +2 -2
- package/src/validators/utils/postal_code.ts +2 -2
- package/src/validators/utils/text_limit.ts +2 -2
- package/types.d.ts +11 -5
- package/types.js +1 -0
- package/utils.d.ts +4 -1
- package/utils.js +56 -0
- package/validators/index.d.ts +6 -6
- package/validators/index.js +112 -139
- package/validators/types.d.ts +1 -1
- package/validators/types.js +0 -0
- package/validators/utils/afm.js +19 -0
- package/validators/utils/amka.d.ts +6 -0
- package/validators/utils/amka.js +27 -0
- package/validators/utils/date.d.ts +3 -3
- package/validators/utils/date.js +95 -0
- package/validators/utils/datetime.d.ts +3 -3
- package/validators/utils/datetime.js +121 -0
- package/validators/utils/email.d.ts +5 -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 -13
- package/validators/utils/index.js +59 -90
- 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 -117
- package/Field/FieldBase/package.json +0 -6
- package/Field/FieldBase.js.map +0 -7
- package/Field/FieldBaseContainer/index.js +0 -33
- package/Field/FieldBaseContainer/package.json +0 -6
- package/Field/FieldBaseContainer.js.map +0 -7
- package/Field/FieldConditional/index.js +0 -85
- 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/calculateField/index.js +0 -27
- package/Field/utils/calculateField/package.json +0 -6
- package/Field/utils/calculateField.d.ts +0 -2
- package/Field/utils/calculateField.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/index.js +0 -84
- package/Field/utils/index.js.map +0 -7
- package/Field/utils/package.json +0 -6
- package/Field/utils/useField/index.js +0 -57
- package/Field/utils/useField/package.json +0 -6
- package/Field/utils/useField.js.map +0 -7
- package/FieldArray/FieldArray.stories.d.ts +0 -10
- package/FieldArray/FormDialog/package.json +0 -6
- package/FieldArray/FormDialog.d.ts +0 -53
- package/FieldArray/FormDialog.js.map +0 -7
- 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/index.test.d.ts +0 -1
- 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/index.test.d.ts +0 -1
- package/FormBuilder/interaction.test.d.ts +0 -1
- package/FormBuilder/package.json +0 -6
- package/FormBuilder/scenarios.test.d.ts +0 -88
- package/FormContext/index.js +0 -9
- 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 -153
- 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/index.test.d.ts +0 -1
- 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/index.spec.d.ts +0 -1
- package/Questions/index.test.d.ts +0 -1
- 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 -150
- package/cjs/Field/FieldBase.js.map +0 -7
- package/cjs/Field/FieldBaseContainer/index.js +0 -66
- package/cjs/Field/FieldBaseContainer.js.map +0 -7
- package/cjs/Field/FieldConditional/index.js +0 -118
- package/cjs/Field/FieldConditional.js.map +0 -7
- package/cjs/Field/index.js +0 -144
- 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/calculateField/index.js +0 -50
- package/cjs/Field/utils/calculateField.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/index.js +0 -119
- package/cjs/Field/utils/index.js.map +0 -7
- package/cjs/Field/utils/useField/index.js +0 -80
- package/cjs/Field/utils/useField.js.map +0 -7
- package/cjs/FieldArray/FormDialog/index.js +0 -301
- package/cjs/FieldArray/FormDialog.js.map +0 -7
- package/cjs/FieldArray/index.js +0 -143
- package/cjs/FieldArray/index.js.map +0 -7
- package/cjs/FieldObject/index.js +0 -106
- 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 -273
- package/cjs/FormBuilder/index.js.map +0 -7
- package/cjs/FormContext/index.js +0 -32
- package/cjs/FormContext.js.map +0 -7
- package/cjs/MultiplicityField/add-objects/index.js +0 -181
- package/cjs/MultiplicityField/add-objects.js.map +0 -7
- package/cjs/MultiplicityField/index.js +0 -150
- 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/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 -107
- package/cjs/inputs/Checkboxes/index.js.map +0 -7
- package/cjs/inputs/DateInput/index.js +0 -156
- package/cjs/inputs/DateInput/index.js.map +0 -7
- package/cjs/inputs/DateTimeInput/index.js +0 -211
- package/cjs/inputs/DateTimeInput/index.js.map +0 -7
- package/cjs/inputs/FileInput/index.js +0 -95
- package/cjs/inputs/FileInput/index.js.map +0 -7
- package/cjs/inputs/ImageInput/index.js +0 -99
- package/cjs/inputs/ImageInput/index.js.map +0 -7
- package/cjs/inputs/Input/index.js +0 -111
- package/cjs/inputs/Input/index.js.map +0 -7
- package/cjs/inputs/Input/inputsInputScenarios/index.js +0 -439
- package/cjs/inputs/Input/inputsInputScenarios.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 -181
- package/cjs/inputs/OtpInput/index.js.map +0 -7
- package/cjs/inputs/Radio/index.js +0 -134
- package/cjs/inputs/Radio/index.js.map +0 -7
- package/cjs/inputs/Select/index.js +0 -62
- 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/inputsScenarios/index.js +0 -533
- package/cjs/inputs/inputsScenarios.js.map +0 -7
- package/cjs/internal/index.js +0 -38
- package/cjs/internal.js.map +0 -7
- package/cjs/lazy/index.js +0 -110
- package/cjs/lazy.js.map +0 -7
- package/cjs/locales/el/index.js +0 -35
- package/cjs/locales/el.js.map +0 -7
- package/cjs/registry/index.js +0 -195
- 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 -83
- package/cjs/utils.js.map +0 -7
- package/cjs/validators/index.js +0 -160
- 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/date/index.js +0 -138
- package/cjs/validators/utils/date.js.map +0 -7
- package/cjs/validators/utils/datetime/index.js +0 -151
- package/cjs/validators/utils/datetime.js.map +0 -7
- package/cjs/validators/utils/file/index.js +0 -48
- 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 -144
- 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/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/index.test.d.ts +0 -1
- 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/index.test.d.ts +0 -1
- package/inputs/Checkboxes/package.json +0 -6
- package/inputs/DateInput/DateInput.stories.d.ts +0 -10
- package/inputs/DateInput/__stories__/Default.d.ts +0 -3
- package/inputs/DateInput/index.js.map +0 -7
- package/inputs/DateInput/index.test.d.ts +0 -1
- package/inputs/DateInput/package.json +0 -6
- package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +0 -9
- package/inputs/DateTimeInput/__stories__/Default.d.ts +0 -3
- package/inputs/DateTimeInput/index.js.map +0 -7
- package/inputs/DateTimeInput/index.test.d.ts +0 -1
- package/inputs/DateTimeInput/package.json +0 -6
- package/inputs/FileInput/FileInput.stories.d.ts +0 -10
- package/inputs/FileInput/__stories__/Default.d.ts +0 -3
- package/inputs/FileInput/index.js.map +0 -7
- package/inputs/FileInput/index.test.d.ts +0 -1
- package/inputs/FileInput/package.json +0 -6
- package/inputs/ImageInput/ImageInput.stories.d.ts +0 -12
- package/inputs/ImageInput/__stories__/Default.d.ts +0 -3
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +0 -3
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +0 -3
- package/inputs/ImageInput/index.js.map +0 -7
- package/inputs/ImageInput/index.test.d.ts +0 -1
- package/inputs/ImageInput/package.json +0 -6
- package/inputs/Input/Input.stories.d.ts +0 -20
- package/inputs/Input/__stories__/AFM.d.ts +0 -3
- package/inputs/Input/__stories__/Boolean.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__/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/index.test.d.ts +0 -1
- package/inputs/Input/inputsInputScenarios/index.js +0 -406
- package/inputs/Input/inputsInputScenarios/package.json +0 -6
- package/inputs/Input/inputsInputScenarios.d.ts +0 -57
- package/inputs/Input/inputsInputScenarios.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/index.test.d.ts +0 -1
- 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/index.test.d.ts +0 -1
- 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/index.test.d.ts +0 -1
- 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/index.test.d.ts +0 -1
- package/inputs/Select/package.json +0 -6
- package/inputs/index.js.map +0 -7
- package/inputs/inputsScenarios/index.js +0 -499
- package/inputs/inputsScenarios/package.json +0 -6
- package/inputs/inputsScenarios.d.ts +0 -296
- package/inputs/inputsScenarios.js.map +0 -7
- package/inputs/package.json +0 -6
- 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/locales/el/index.js +0 -6
- package/locales/el/package.json +0 -6
- package/locales/el.d.ts +0 -2
- package/locales/el.js.map +0 -7
- package/registry/package.json +0 -6
- package/src/Field/utils/calculateField.ts +0 -49
- package/src/FieldArray/FormDialog.tsx +0 -378
- package/src/inputs/Input/inputsInputScenarios.ts +0 -404
- package/src/inputs/inputsScenarios.ts +0 -496
- package/src/lazy.js +0 -77
- package/src/locales/el.ts +0 -3
- package/src/registry.js +0 -165
- package/types/index.js +0 -2
- package/types/package.json +0 -6
- package/types.js.map +0 -7
- package/utils/index.js +0 -60
- 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/date/index.js +0 -103
- package/validators/utils/date/package.json +0 -6
- package/validators/utils/date.js.map +0 -7
- package/validators/utils/datetime/index.js +0 -116
- package/validators/utils/datetime/package.json +0 -6
- package/validators/utils/datetime.js.map +0 -7
- package/validators/utils/file/index.js +0 -25
- 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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
function validateIban(value, countryCode) {
|
|
2
|
+
value = value.replace(/\s/g, '').replace(/-/g, '');
|
|
3
|
+
if (value.match(/^[0-9]*$/i)) {
|
|
4
|
+
if (25 !== value.length) return false;
|
|
5
|
+
} else {
|
|
6
|
+
value = value.toUpperCase();
|
|
7
|
+
if (countryCode) {
|
|
8
|
+
if (!value.startsWith(countryCode.toUpperCase())) return false;
|
|
9
|
+
if (value.length === ibanCountryCodesLengths[countryCode.toUpperCase()]) return true;
|
|
10
|
+
}
|
|
11
|
+
if (27 !== value.length) return false;
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
const IBAN_VALIDATOR = (field)=>{
|
|
16
|
+
const countryCode = field?.extra?.country;
|
|
17
|
+
return {
|
|
18
|
+
name: 'iban-validator',
|
|
19
|
+
message: 'form.error.iban',
|
|
20
|
+
test: (value)=>{
|
|
21
|
+
if (!value) return true;
|
|
22
|
+
return validateIban(value, countryCode);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const ibanCountryCodesLengths = {
|
|
27
|
+
AD: 24,
|
|
28
|
+
AT: 20,
|
|
29
|
+
AZ: 28,
|
|
30
|
+
BH: 22,
|
|
31
|
+
BY: 28,
|
|
32
|
+
BE: 16,
|
|
33
|
+
BA: 20,
|
|
34
|
+
BR: 29,
|
|
35
|
+
BG: 22,
|
|
36
|
+
CR: 22,
|
|
37
|
+
HR: 21,
|
|
38
|
+
CY: 28,
|
|
39
|
+
CZ: 24,
|
|
40
|
+
DK: 18,
|
|
41
|
+
DO: 28,
|
|
42
|
+
EG: 29,
|
|
43
|
+
SV: 28,
|
|
44
|
+
EE: 20,
|
|
45
|
+
FO: 18,
|
|
46
|
+
FI: 18,
|
|
47
|
+
FR: 27,
|
|
48
|
+
GE: 22,
|
|
49
|
+
DE: 22,
|
|
50
|
+
GI: 23,
|
|
51
|
+
GR: 27,
|
|
52
|
+
GL: 18,
|
|
53
|
+
GT: 28,
|
|
54
|
+
VA: 22,
|
|
55
|
+
HU: 28,
|
|
56
|
+
IS: 26,
|
|
57
|
+
IQ: 23,
|
|
58
|
+
IE: 22,
|
|
59
|
+
IL: 23,
|
|
60
|
+
IT: 27,
|
|
61
|
+
JO: 30,
|
|
62
|
+
KZ: 20,
|
|
63
|
+
XK: 20,
|
|
64
|
+
KW: 30,
|
|
65
|
+
LV: 21,
|
|
66
|
+
LB: 28,
|
|
67
|
+
LI: 21,
|
|
68
|
+
LT: 20,
|
|
69
|
+
LU: 20,
|
|
70
|
+
MT: 31,
|
|
71
|
+
MR: 27,
|
|
72
|
+
MU: 30,
|
|
73
|
+
MD: 24,
|
|
74
|
+
MC: 27,
|
|
75
|
+
ME: 22,
|
|
76
|
+
NL: 18,
|
|
77
|
+
MK: 19,
|
|
78
|
+
NO: 15,
|
|
79
|
+
PK: 24,
|
|
80
|
+
PS: 29,
|
|
81
|
+
PL: 28,
|
|
82
|
+
PT: 25,
|
|
83
|
+
QA: 29,
|
|
84
|
+
RO: 24,
|
|
85
|
+
LC: 32,
|
|
86
|
+
SM: 27,
|
|
87
|
+
ST: 25,
|
|
88
|
+
SA: 24,
|
|
89
|
+
RS: 22,
|
|
90
|
+
SC: 31,
|
|
91
|
+
SK: 24,
|
|
92
|
+
SI: 19,
|
|
93
|
+
ES: 24,
|
|
94
|
+
SE: 24,
|
|
95
|
+
CH: 21,
|
|
96
|
+
TL: 23,
|
|
97
|
+
TN: 24,
|
|
98
|
+
TR: 26,
|
|
99
|
+
UA: 29,
|
|
100
|
+
AE: 23,
|
|
101
|
+
GB: 22,
|
|
102
|
+
VG: 24
|
|
103
|
+
};
|
|
104
|
+
export { IBAN_VALIDATOR, validateIban };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FieldSpec } from '
|
|
2
|
-
import { ValidatorSchema } from '
|
|
1
|
+
import type { FieldSpec } from '../../types.js';
|
|
2
|
+
import type { ValidatorSchema } from '../types.js';
|
|
3
3
|
export declare const IMAGE_DIMENSION_VALIDATOR: (field: FieldSpec) => ValidatorSchema;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const DEFAULT_IMAGE_MAX_HEIGHT_SIZE = 2000;
|
|
2
|
+
const DEFAULT_IMAGE_MAX_WIDTH_SIZE = 2000;
|
|
3
|
+
const DEFAULT_IMAGE_MIN_HEIGHT_SIZE = 100;
|
|
4
|
+
const DEFAULT_IMAGE_MIN_WIDTH_SIZE = 100;
|
|
5
|
+
function getImageDimensions(file) {
|
|
6
|
+
return new Promise((resolve, reject)=>{
|
|
7
|
+
const reader = new FileReader();
|
|
8
|
+
reader.onload = (event)=>{
|
|
9
|
+
const img = new Image();
|
|
10
|
+
img.onload = ()=>{
|
|
11
|
+
resolve({
|
|
12
|
+
width: img.width,
|
|
13
|
+
height: img.height
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
img.onerror = reject;
|
|
17
|
+
const result = event?.target?.result;
|
|
18
|
+
if (result && 'string' == typeof result) img.src = result;
|
|
19
|
+
else reject(new Error('Invalid file format'));
|
|
20
|
+
};
|
|
21
|
+
reader.onerror = reject;
|
|
22
|
+
reader.readAsDataURL(file);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const IMAGE_DIMENSION_VALIDATOR = (field)=>({
|
|
26
|
+
name: 'image-dimension-validator',
|
|
27
|
+
message: (value)=>{
|
|
28
|
+
const minHeight = field?.extra?.limit?.minHeight || DEFAULT_IMAGE_MIN_HEIGHT_SIZE;
|
|
29
|
+
const minWidth = field?.extra?.limit?.minWidth || DEFAULT_IMAGE_MIN_WIDTH_SIZE;
|
|
30
|
+
const maxHeight = field?.extra?.limit?.maxHeight || DEFAULT_IMAGE_MAX_HEIGHT_SIZE;
|
|
31
|
+
const maxWidth = field?.extra?.limit?.maxWidth || DEFAULT_IMAGE_MAX_WIDTH_SIZE;
|
|
32
|
+
if (!value || 0 === value.length) return {
|
|
33
|
+
name: 'image-validator',
|
|
34
|
+
message: 'form.error.required'
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
key: 'form.error.image.image_dimension_size',
|
|
38
|
+
context: {
|
|
39
|
+
maxHeight: maxHeight,
|
|
40
|
+
maxWidth: maxWidth,
|
|
41
|
+
minHeight: minHeight,
|
|
42
|
+
minWidth: minWidth
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
test: async (value)=>{
|
|
47
|
+
if (!value || 0 === value.length) return true;
|
|
48
|
+
const file = value[0];
|
|
49
|
+
const { width, height } = await getImageDimensions(file);
|
|
50
|
+
const maxHeight = field?.extra?.limit?.maxHeight || DEFAULT_IMAGE_MAX_HEIGHT_SIZE;
|
|
51
|
+
const maxWidth = field?.extra?.limit?.maxWidth || DEFAULT_IMAGE_MAX_WIDTH_SIZE;
|
|
52
|
+
const minHeight = field?.extra?.limit?.minHeight || DEFAULT_IMAGE_MIN_HEIGHT_SIZE;
|
|
53
|
+
const minWidth = field?.extra?.limit?.minWidth || DEFAULT_IMAGE_MIN_WIDTH_SIZE;
|
|
54
|
+
if (!file) return true;
|
|
55
|
+
try {
|
|
56
|
+
if (height > maxHeight || width > maxWidth) return false;
|
|
57
|
+
if (height < minHeight || width < minWidth) return false;
|
|
58
|
+
return true;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error('Error getting image dimensions:', error);
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
export { IMAGE_DIMENSION_VALIDATOR };
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
import { FieldSpec } from '
|
|
3
|
-
import { ValidatorSchema } from '
|
|
4
|
-
export * from '
|
|
5
|
-
export * from '
|
|
6
|
-
export * from '
|
|
7
|
-
export * from '
|
|
8
|
-
export * from '
|
|
9
|
-
export * from '
|
|
10
|
-
export * from '
|
|
11
|
-
export * from '
|
|
12
|
-
export * from '
|
|
13
|
-
export * from '
|
|
14
|
-
export * from '
|
|
2
|
+
import type { FieldSpec } from '../../types.js';
|
|
3
|
+
import type { ValidatorSchema } from '../types.js';
|
|
4
|
+
export * from './afm.js';
|
|
5
|
+
export * from './amka.js';
|
|
6
|
+
export * from './file.js';
|
|
7
|
+
export * from './iban.js';
|
|
8
|
+
export * from './otp.js';
|
|
9
|
+
export * from './image.js';
|
|
10
|
+
export * from './phone.js';
|
|
11
|
+
export * from './postal_code.js';
|
|
12
|
+
export * from './uuid4.js';
|
|
13
|
+
export * from './text_limit.js';
|
|
14
|
+
export * from './date.js';
|
|
15
|
+
export * from './datetime.js';
|
|
15
16
|
export declare function getYupField(field: FieldSpec, yupTypeMap: Record<string, any>): any;
|
|
16
17
|
export declare function computeShape(fields: FieldSpec[], yupTypeMap: Record<string, ValidatorSchema>, validatorRegistry: Record<string, ValidatorSchema[]> | undefined): {};
|
|
17
18
|
export declare function getYupObjectShape(fields: FieldSpec[] | any, yupTypeMap: Record<string, any>, validatorRegistry?: Record<string, ValidatorSchema[]>): yup.ObjectSchema<{
|
|
@@ -1,97 +1,66 @@
|
|
|
1
|
-
import
|
|
2
|
-
export * from "
|
|
3
|
-
export * from "
|
|
4
|
-
export * from "
|
|
5
|
-
export * from "
|
|
6
|
-
export * from "
|
|
7
|
-
export * from "
|
|
8
|
-
export * from "
|
|
9
|
-
export * from "
|
|
10
|
-
export * from "
|
|
11
|
-
export * from "
|
|
12
|
-
export * from "
|
|
1
|
+
import { lazy, object } from "yup";
|
|
2
|
+
export * from "./afm.js";
|
|
3
|
+
export * from "./amka.js";
|
|
4
|
+
export * from "./file.js";
|
|
5
|
+
export * from "./iban.js";
|
|
6
|
+
export * from "./otp.js";
|
|
7
|
+
export * from "./image.js";
|
|
8
|
+
export * from "./phone.js";
|
|
9
|
+
export * from "./postal_code.js";
|
|
10
|
+
export * from "./uuid4.js";
|
|
11
|
+
export * from "./text_limit.js";
|
|
12
|
+
export * from "./date.js";
|
|
13
|
+
export * from "./datetime.js";
|
|
13
14
|
function getYupField(field, yupTypeMap) {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const yupField = yupTypeMap[field?.type || 'string'] || yupTypeMap['string'];
|
|
16
|
+
return yupField(field);
|
|
16
17
|
}
|
|
17
18
|
function computeShape(fields, yupTypeMap, validatorRegistry) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
const fieldSchemas = {};
|
|
20
|
+
const objectFields = {};
|
|
21
|
+
fields.forEach((field)=>{
|
|
22
|
+
let yupField = getYupField(field, yupTypeMap);
|
|
23
|
+
if (field.condition) for(const key in field.condition){
|
|
24
|
+
let then, otherwise;
|
|
25
|
+
if (field.condition[key].then) {
|
|
26
|
+
if (field.condition[key].then?.required === false) then = yupField.nullable();
|
|
27
|
+
else if (field.condition[key].then?.required === true) then = yupField.nullable().required('form.error.required');
|
|
28
|
+
}
|
|
29
|
+
if (field.condition[key].else) {
|
|
30
|
+
if (field.condition[key].else?.required === false) otherwise = yupField.nullable();
|
|
31
|
+
else if (field.condition[key].else?.required === true) otherwise = yupField.nullable().required('form.error.required');
|
|
32
|
+
}
|
|
33
|
+
if (then || otherwise) yupField = yupField.when(key, {
|
|
34
|
+
is: (val)=>{
|
|
35
|
+
const is = field.condition[key].is;
|
|
36
|
+
if (is === val || Array.isArray(val) && val.includes(is)) return true;
|
|
37
|
+
return false;
|
|
38
|
+
},
|
|
39
|
+
then,
|
|
40
|
+
otherwise
|
|
41
|
+
});
|
|
31
42
|
}
|
|
32
|
-
if (field.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return true;
|
|
45
|
-
} else {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
then,
|
|
50
|
-
otherwise
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
} else if (field.required) {
|
|
55
|
-
yupField = yupField.nullable().required("form.error.required");
|
|
56
|
-
}
|
|
57
|
-
if (validatorRegistry && field.type && validatorRegistry[field.type]) {
|
|
58
|
-
validatorRegistry[field.type].forEach((validator) => {
|
|
59
|
-
yupField = yupField.test(validator);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
if (field.validators) {
|
|
63
|
-
field.validators.forEach((validator) => {
|
|
64
|
-
yupField = yupField.test(validator);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
fieldSchemas[field.key] = yupField;
|
|
68
|
-
});
|
|
69
|
-
for (const objectKey in objectFields) {
|
|
70
|
-
fieldSchemas[objectKey] = getYupObjectShape(
|
|
71
|
-
objectFields[objectKey],
|
|
72
|
-
yupTypeMap,
|
|
73
|
-
validatorRegistry
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
return fieldSchemas;
|
|
43
|
+
else if (field.required) yupField = yupField.nullable().required('form.error.required');
|
|
44
|
+
if (validatorRegistry && field.type && validatorRegistry[field.type]) if (Array.isArray(validatorRegistry[field.type])) validatorRegistry[field.type].forEach((validator)=>{
|
|
45
|
+
yupField = yupField.test(validator);
|
|
46
|
+
});
|
|
47
|
+
else yupField = yupField.test(validatorRegistry[field.type]);
|
|
48
|
+
if (field.validators) field.validators.forEach((validator)=>{
|
|
49
|
+
yupField = yupField.test(validator);
|
|
50
|
+
});
|
|
51
|
+
fieldSchemas[field.key] = yupField;
|
|
52
|
+
});
|
|
53
|
+
for(const objectKey in objectFields)fieldSchemas[objectKey] = getYupObjectShape(objectFields[objectKey], yupTypeMap, validatorRegistry);
|
|
54
|
+
return fieldSchemas;
|
|
77
55
|
}
|
|
78
56
|
function getYupObjectShape(fields, yupTypeMap, validatorRegistry) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
validatorRegistry
|
|
88
|
-
);
|
|
89
|
-
return yup.object().shape(fieldSchemas);
|
|
90
|
-
});
|
|
57
|
+
if (!fields.current) {
|
|
58
|
+
const fieldSchemas = computeShape(fields, yupTypeMap, validatorRegistry);
|
|
59
|
+
return object().shape(fieldSchemas);
|
|
60
|
+
}
|
|
61
|
+
return lazy(function() {
|
|
62
|
+
const fieldSchemas = computeShape(Object.values(fields.current).filter((f)=>!f.key.includes('.')), yupTypeMap, validatorRegistry);
|
|
63
|
+
return object().shape(fieldSchemas);
|
|
64
|
+
});
|
|
91
65
|
}
|
|
92
|
-
export {
|
|
93
|
-
computeShape,
|
|
94
|
-
getYupField,
|
|
95
|
-
getYupObjectShape
|
|
96
|
-
};
|
|
97
|
-
//# sourceMappingURL=index.js.map
|
|
66
|
+
export { computeShape, getYupField, getYupObjectShape };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function validateIntNumber(number) {
|
|
2
|
+
if (void 0 === number) return false;
|
|
3
|
+
return Number.isInteger(number) && Number(number) > 0;
|
|
4
|
+
}
|
|
5
|
+
const INT_VALIDATOR = ()=>({
|
|
6
|
+
name: 'int-validator',
|
|
7
|
+
message: 'form.error.positive_integer_number',
|
|
8
|
+
test: (value)=>{
|
|
9
|
+
if (void 0 === value) return true;
|
|
10
|
+
return validateIntNumber(value);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { INT_VALIDATOR, validateIntNumber };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function validateNumber(number) {
|
|
2
|
+
return !Number.isNaN(number);
|
|
3
|
+
}
|
|
4
|
+
const NUMBER_VALIDATOR = ()=>({
|
|
5
|
+
name: 'number-validator',
|
|
6
|
+
message: 'form.error.number',
|
|
7
|
+
test: (value)=>{
|
|
8
|
+
if (void 0 === value) return true;
|
|
9
|
+
return validateNumber(value);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export { NUMBER_VALIDATOR, validateNumber };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldSpec } from '
|
|
2
|
-
import { ValidatorSchema } from '
|
|
1
|
+
import type { FieldSpec } from '../../types.js';
|
|
2
|
+
import type { ValidatorSchema } from '../types.js';
|
|
3
3
|
export declare function validateOtp(value: string, maxLength: number): boolean;
|
|
4
4
|
export declare const OTP_VALIDATOR: (field: FieldSpec) => ValidatorSchema;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function validateOtp(value, maxLength) {
|
|
2
|
+
if (value.length === maxLength) return true;
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const OTP_VALIDATOR = (field)=>{
|
|
6
|
+
const maxLength = field?.maxLength;
|
|
7
|
+
return {
|
|
8
|
+
name: 'otp-validator',
|
|
9
|
+
message: {
|
|
10
|
+
key: 'form.error.otp.less_than',
|
|
11
|
+
context: {
|
|
12
|
+
maxLength: field?.maxLength
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
test: (value)=>{
|
|
16
|
+
if (!value) return true;
|
|
17
|
+
return validateOtp(value, maxLength);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export { OTP_VALIDATOR, validateOtp };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FieldSpec } from '
|
|
2
|
-
import { ValidatorSchema } from '
|
|
1
|
+
import type { FieldSpec } from '../../types.js';
|
|
2
|
+
import type { ValidatorSchema } from '../types.js';
|
|
3
3
|
export type PhoneNumberType = 'landline' | 'mobile' | null;
|
|
4
4
|
export declare function discoverPhoneType(phoneNumber: string, config: any): string;
|
|
5
5
|
export declare function validatePhoneNumber(phoneNumber: string, countries?: string[], typeOfPhoneNumber?: PhoneNumberType): boolean;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
const countryPhoneData = {
|
|
2
|
+
GR: [
|
|
3
|
+
'30',
|
|
4
|
+
'00',
|
|
5
|
+
'5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}',
|
|
6
|
+
[
|
|
7
|
+
10,
|
|
8
|
+
11,
|
|
9
|
+
12
|
|
10
|
+
],
|
|
11
|
+
[
|
|
12
|
+
[
|
|
13
|
+
'(\\d{2})(\\d{4})(\\d{4})',
|
|
14
|
+
'$1 $2 $3',
|
|
15
|
+
[
|
|
16
|
+
'21|7'
|
|
17
|
+
]
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
'(\\d{4})(\\d{6})',
|
|
21
|
+
'$1 $2',
|
|
22
|
+
[
|
|
23
|
+
'2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5'
|
|
24
|
+
]
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
'(\\d{3})(\\d{3})(\\d{4})',
|
|
28
|
+
'$1 $2 $3',
|
|
29
|
+
[
|
|
30
|
+
'[2689]'
|
|
31
|
+
]
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
'(\\d{3})(\\d{3,4})(\\d{5})',
|
|
35
|
+
'$1 $2 $3',
|
|
36
|
+
[
|
|
37
|
+
'8'
|
|
38
|
+
]
|
|
39
|
+
]
|
|
40
|
+
],
|
|
41
|
+
0,
|
|
42
|
+
0,
|
|
43
|
+
0,
|
|
44
|
+
0,
|
|
45
|
+
0,
|
|
46
|
+
0,
|
|
47
|
+
[
|
|
48
|
+
[
|
|
49
|
+
'2(?:1\\d\\d|2(?:2[1-46-9]|[36][1-8]|4[1-7]|5[1-4]|7[1-5]|[89][1-9])|3(?:1\\d|2[1-57]|[35][1-3]|4[13]|7[1-7]|8[124-6]|9[1-79])|4(?:1\\d|2[1-8]|3[1-4]|4[13-5]|6[1-578]|9[1-5])|5(?:1\\d|[29][1-4]|3[1-5]|4[124]|5[1-6])|6(?:1\\d|[269][1-6]|3[1245]|4[1-7]|5[13-9]|7[14]|8[1-5])|7(?:1\\d|2[1-5]|3[1-6]|4[1-7]|5[1-57]|6[135]|9[125-7])|8(?:1\\d|2[1-5]|[34][1-4]|9[1-57]))\\d{6}',
|
|
50
|
+
[
|
|
51
|
+
10
|
|
52
|
+
]
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
'68[57-9]\\d{7}|(?:69|94)\\d{8}',
|
|
56
|
+
[
|
|
57
|
+
10
|
|
58
|
+
]
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
'800\\d{7,9}'
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
'90[19]\\d{7}',
|
|
65
|
+
[
|
|
66
|
+
10
|
|
67
|
+
]
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
'70\\d{8}',
|
|
71
|
+
[
|
|
72
|
+
10
|
|
73
|
+
]
|
|
74
|
+
],
|
|
75
|
+
0,
|
|
76
|
+
[
|
|
77
|
+
'5005000\\d{3}',
|
|
78
|
+
[
|
|
79
|
+
10
|
|
80
|
+
]
|
|
81
|
+
],
|
|
82
|
+
0,
|
|
83
|
+
0,
|
|
84
|
+
[
|
|
85
|
+
'8(?:0[16]|12|[27]5|50)\\d{7}',
|
|
86
|
+
[
|
|
87
|
+
10
|
|
88
|
+
]
|
|
89
|
+
]
|
|
90
|
+
]
|
|
91
|
+
]
|
|
92
|
+
};
|
|
93
|
+
function expandPhoneNumberStructure(compressed) {
|
|
94
|
+
const countries = Object.keys(compressed);
|
|
95
|
+
const expanded = {};
|
|
96
|
+
for (const country of countries)expanded[country] = {
|
|
97
|
+
fixedLine: {
|
|
98
|
+
possibleLengths: {
|
|
99
|
+
_national: compressed[country][3].map(String)
|
|
100
|
+
},
|
|
101
|
+
nationalNumberPattern: compressed[country][11][0][0]
|
|
102
|
+
},
|
|
103
|
+
mobile: {
|
|
104
|
+
nationalNumberPattern: compressed[country][11][1][0]
|
|
105
|
+
},
|
|
106
|
+
tollFree: {
|
|
107
|
+
nationalNumberPattern: compressed[country][11][2][0]
|
|
108
|
+
},
|
|
109
|
+
premiumRate: {
|
|
110
|
+
nationalNumberPattern: compressed[country][11][3][0]
|
|
111
|
+
},
|
|
112
|
+
sharedCost: {
|
|
113
|
+
nationalNumberPattern: compressed[country][11][9][0]
|
|
114
|
+
},
|
|
115
|
+
personalNumber: {
|
|
116
|
+
nationalNumberPattern: compressed[country][11][4][0]
|
|
117
|
+
},
|
|
118
|
+
uan: {
|
|
119
|
+
nationalNumberPattern: compressed[country][11][6][0]
|
|
120
|
+
},
|
|
121
|
+
id: country,
|
|
122
|
+
countryCode: compressed[country][0],
|
|
123
|
+
internationalPrefix: compressed[country][1]
|
|
124
|
+
};
|
|
125
|
+
return expanded;
|
|
126
|
+
}
|
|
127
|
+
const PHONENUMBER_SPEC = expandPhoneNumberStructure(countryPhoneData);
|
|
128
|
+
function discoverPhoneType(phoneNumber, config) {
|
|
129
|
+
const cleanNumber = phoneNumber.replace(/\D/g, '').replace(/\s/g, '').replace(/^\+/, '').replace(new RegExp('^' + config.internationalPrefix, ''), '').replace(new RegExp('^' + config.countryCode, ''), '');
|
|
130
|
+
const categories = {
|
|
131
|
+
landline: config.fixedLine,
|
|
132
|
+
mobile: config.mobile,
|
|
133
|
+
'toll-free': config.tollFree,
|
|
134
|
+
'premium-rate': config.premiumRate
|
|
135
|
+
};
|
|
136
|
+
for (const [categoryName, categoryDetails] of Object.entries(categories)){
|
|
137
|
+
const pattern = new RegExp('^(' + categoryDetails.nationalNumberPattern.replace(/\s/g, '') + ')$', '');
|
|
138
|
+
if (cleanNumber.match(pattern)) return categoryName;
|
|
139
|
+
}
|
|
140
|
+
return 'unknown';
|
|
141
|
+
}
|
|
142
|
+
function getNumberType(phoneNumber, country) {
|
|
143
|
+
const spec = PHONENUMBER_SPEC[country.toUpperCase()];
|
|
144
|
+
if (!spec) throw new Error(`Country ${country} is not supported`);
|
|
145
|
+
const type = discoverPhoneType(phoneNumber, spec);
|
|
146
|
+
return type;
|
|
147
|
+
}
|
|
148
|
+
function isPhoneNumberValid(phoneNumber, countries, types = [
|
|
149
|
+
'mobile',
|
|
150
|
+
'landline'
|
|
151
|
+
]) {
|
|
152
|
+
return countries.some((country)=>{
|
|
153
|
+
const numberType = getNumberType(phoneNumber, country);
|
|
154
|
+
if (numberType && types.includes(numberType)) return true;
|
|
155
|
+
return false;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function isNumberOfType(phoneNumber, country, type) {
|
|
159
|
+
const numberType = getNumberType(phoneNumber, country);
|
|
160
|
+
if (numberType === type) return true;
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
function validatePhoneNumber(phoneNumber, countries = [
|
|
164
|
+
'gr'
|
|
165
|
+
], typeOfPhoneNumber) {
|
|
166
|
+
if (!countries || 0 === countries.length) return true;
|
|
167
|
+
return isPhoneNumberValid(phoneNumber, countries, typeOfPhoneNumber ? [
|
|
168
|
+
typeOfPhoneNumber
|
|
169
|
+
] : void 0);
|
|
170
|
+
}
|
|
171
|
+
function validateMobile(value) {
|
|
172
|
+
return isNumberOfType(value, 'gr', 'mobile');
|
|
173
|
+
}
|
|
174
|
+
const MOBILE_PHONE_VALIDATOR = {
|
|
175
|
+
name: 'mobile-phone-validator',
|
|
176
|
+
message: 'form.error.mobile_phone',
|
|
177
|
+
test: (value)=>{
|
|
178
|
+
if (value) return validateMobile(value);
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const PHONE_NUMBER_VALIDATOR = (field)=>{
|
|
183
|
+
const countryCodes = field?.extra?.countries;
|
|
184
|
+
const typeOfPhone = field?.extra?.phoneType;
|
|
185
|
+
return {
|
|
186
|
+
name: 'phone-number-validator',
|
|
187
|
+
message: ()=>{
|
|
188
|
+
if ('mobile' === typeOfPhone) return 'form.error.mobile_phone';
|
|
189
|
+
if ('landline' === typeOfPhone) return 'form.error.landline';
|
|
190
|
+
return 'form.error.phone_number';
|
|
191
|
+
},
|
|
192
|
+
test: (value)=>{
|
|
193
|
+
if (!value) return true;
|
|
194
|
+
return validatePhoneNumber(value, countryCodes, typeOfPhone);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
export { MOBILE_PHONE_VALIDATOR, PHONE_NUMBER_VALIDATOR, discoverPhoneType, validatePhoneNumber };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldSpec } from '
|
|
2
|
-
import { ValidatorSchema } from '
|
|
1
|
+
import type { FieldSpec } from '../../types.js';
|
|
2
|
+
import type { ValidatorSchema } from '../types.js';
|
|
3
3
|
export declare function validatePostalCode(number: string, countries: string[]): boolean;
|
|
4
4
|
export declare const POSTALCODE_VALIDATOR: (field: FieldSpec) => ValidatorSchema;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const CODE_REGEX = /^[12345678][0-9]{4}$/;
|
|
2
|
+
function validatePostalCode(number, countries) {
|
|
3
|
+
if (!countries) return false;
|
|
4
|
+
if (1 === countries.length && 'GR' === countries[0].toUpperCase()) return CODE_REGEX.test(number);
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
const POSTALCODE_VALIDATOR = (field)=>{
|
|
8
|
+
const countryCode = field?.extra?.countries;
|
|
9
|
+
return {
|
|
10
|
+
name: 'postal-code-validator',
|
|
11
|
+
message: 'form.error.postalCode',
|
|
12
|
+
test: (value)=>{
|
|
13
|
+
if (!value) return true;
|
|
14
|
+
return validatePostalCode(value, countryCode);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export { POSTALCODE_VALIDATOR, validatePostalCode };
|