@digigov/form 1.0.0-079f34f3d → 1.0.0-23c81d9f
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/{es/Field/FieldBase.js → Field/FieldBase/index.js} +1 -1
- package/Field/FieldBase/package.json +6 -0
- package/{esm/Field/FieldBaseContainer.js → Field/FieldBaseContainer/index.js} +1 -1
- package/Field/FieldBaseContainer/package.json +6 -0
- package/{es/Field/FieldConditional.js → Field/FieldConditional/index.js} +2 -2
- package/Field/FieldConditional/package.json +6 -0
- package/Field/index.js +18 -45
- package/Field/package.json +6 -0
- package/Field/types/package.json +6 -0
- package/{es/Field/utils.js → Field/utils/index.js} +14 -9
- package/Field/utils/package.json +6 -0
- package/FieldArray/FieldArray.stories/index.js +8 -0
- package/FieldArray/FieldArray.stories/package.json +6 -0
- package/{esm/FieldArray/__stories__/Default.js → FieldArray/__stories__/Default/index.js} +1 -1
- package/FieldArray/__stories__/Default/package.json +6 -0
- package/{es/FieldArray/__stories__/WithExactLength.js → FieldArray/__stories__/WithExactLength/index.js} +1 -1
- package/FieldArray/__stories__/WithExactLength/package.json +6 -0
- package/FieldArray/index.js +19 -41
- package/FieldArray/package.json +6 -0
- package/FieldObject/index.js +16 -41
- package/FieldObject/package.json +6 -0
- package/{esm/Fieldset/FieldsetWithContext.js → Fieldset/FieldsetWithContext/index.js} +3 -3
- package/Fieldset/FieldsetWithContext/package.json +6 -0
- package/Fieldset/index.js +21 -51
- package/Fieldset/package.json +6 -0
- package/Fieldset/types/package.json +6 -0
- package/Form.stories/package.json +6 -0
- package/{es/FormBuilder/FormBuilder.js → FormBuilder/FormBuilder/index.js} +5 -5
- package/FormBuilder/FormBuilder/package.json +6 -0
- package/FormBuilder/FormBuilder.stories/index.js +7 -0
- package/FormBuilder/FormBuilder.stories/package.json +6 -0
- package/{es/FormBuilder/__stories__/Default.js → FormBuilder/__stories__/Default/index.js} +1 -1
- package/FormBuilder/__stories__/Default/package.json +6 -0
- package/FormBuilder/index.js +2 -11
- package/FormBuilder/package.json +6 -0
- package/FormContext/package.json +6 -0
- package/MultiplicityField/MultiplicityField.stories/index.js +12 -0
- package/MultiplicityField/MultiplicityField.stories/package.json +6 -0
- package/{es/MultiplicityField/__stories__/Default.js → MultiplicityField/__stories__/Default/index.js} +1 -1
- package/MultiplicityField/__stories__/Default/package.json +6 -0
- package/MultiplicityField/__stories__/PreviewDisplay/package.json +6 -0
- package/{es/MultiplicityField/__stories__/WithExactLength.js → MultiplicityField/__stories__/WithExactLength/index.js} +1 -1
- package/MultiplicityField/__stories__/WithExactLength/package.json +6 -0
- package/{es/MultiplicityField/__stories__/WithMaxLength.js → MultiplicityField/__stories__/WithMaxLength/index.js} +1 -1
- package/MultiplicityField/__stories__/WithMaxLength/package.json +6 -0
- package/{esm/MultiplicityField/__stories__/WithMinAndMaxLength.js → MultiplicityField/__stories__/WithMinAndMaxLength/index.js} +1 -1
- package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +6 -0
- package/{esm/MultiplicityField/__stories__/WithMinLength.js → MultiplicityField/__stories__/WithMinLength/index.js} +1 -1
- package/MultiplicityField/__stories__/WithMinLength/package.json +6 -0
- package/{esm/MultiplicityField/add-objects.js → MultiplicityField/add-objects/index.js} +3 -3
- package/MultiplicityField/add-objects/package.json +6 -0
- package/MultiplicityField/index.js +26 -55
- package/MultiplicityField/package.json +6 -0
- package/{es/Questions/Questions.js → Questions/Questions/index.js} +2 -2
- package/Questions/Questions/package.json +6 -0
- package/Questions/Questions.stories/index.js +7 -0
- package/Questions/Questions.stories/package.json +6 -0
- package/Questions/QuestionsContext/package.json +6 -0
- package/{esm/Questions/Step/ReviewStep.js → Questions/Step/ReviewStep/index.js} +3 -3
- package/Questions/Step/ReviewStep/package.json +6 -0
- package/{es/Questions/Step/Step.js → Questions/Step/Step/index.js} +3 -3
- package/Questions/Step/Step/package.json +6 -0
- package/{esm/Questions/Step/StepArrayReview.js → Questions/Step/StepArrayReview/index.js} +6 -6
- package/Questions/Step/StepArrayReview/package.json +6 -0
- package/Questions/Step/StepContext/package.json +6 -0
- package/{esm/Questions/Step/StepDescription.js → Questions/Step/StepDescription/index.js} +1 -1
- package/Questions/Step/StepDescription/package.json +6 -0
- package/{esm/Questions/Step/StepForm.js → Questions/Step/StepForm/index.js} +4 -4
- package/Questions/Step/StepForm/package.json +6 -0
- package/Questions/Step/StepQuote/package.json +6 -0
- package/{esm/Questions/Step/StepTitle.js → Questions/Step/StepTitle/index.js} +1 -1
- package/Questions/Step/StepTitle/package.json +6 -0
- package/Questions/Step/getAddMoreFields/package.json +6 -0
- package/Questions/Step/index.d.ts +4 -4
- package/Questions/Step/index.js +13 -153
- package/Questions/Step/package.json +6 -0
- package/Questions/Step/types/package.json +6 -0
- package/{es/Questions/__stories__/Default.js → Questions/__stories__/Default/index.js} +2 -2
- package/Questions/__stories__/Default/package.json +6 -0
- package/Questions/getNextStep/package.json +6 -0
- package/Questions/index.js +3 -25
- package/{esm/Questions/index.spec.js → Questions/index.spec/index.js} +3 -3
- package/Questions/index.spec/package.json +6 -0
- package/Questions/package.json +6 -0
- package/Questions/types/package.json +6 -0
- package/{Field/FieldBase.js → cjs/Field/FieldBase/index.js} +1 -1
- package/{Field/FieldBaseContainer.js → cjs/Field/FieldBaseContainer/index.js} +8 -8
- package/{Field/FieldConditional.js → cjs/Field/FieldConditional/index.js} +2 -2
- package/cjs/Field/index.js +103 -0
- package/{Field/utils.js → cjs/Field/utils/index.js} +15 -9
- package/{FieldArray/FieldArray.stories.js → cjs/FieldArray/FieldArray.stories/index.js} +4 -4
- package/{FieldArray/__stories__/Default.js → cjs/FieldArray/__stories__/Default/index.js} +6 -6
- package/{FieldArray/__stories__/WithExactLength.js → cjs/FieldArray/__stories__/WithExactLength/index.js} +6 -6
- package/cjs/FieldArray/index.js +87 -0
- package/cjs/FieldObject/index.js +83 -0
- package/{Fieldset/FieldsetWithContext.js → cjs/Fieldset/FieldsetWithContext/index.js} +6 -6
- package/cjs/Fieldset/index.js +64 -0
- package/{FormBuilder/FormBuilder.js → cjs/FormBuilder/FormBuilder/index.js} +6 -6
- package/{FormBuilder/FormBuilder.stories.js → cjs/FormBuilder/FormBuilder.stories/index.js} +3 -3
- package/{FormBuilder/__stories__/Default.js → cjs/FormBuilder/__stories__/Default/index.js} +4 -4
- package/cjs/FormBuilder/index.js +11 -0
- package/{MultiplicityField/MultiplicityField.stories.js → cjs/MultiplicityField/MultiplicityField.stories/index.js} +8 -8
- package/{MultiplicityField/__stories__/Default.js → cjs/MultiplicityField/__stories__/Default/index.js} +6 -6
- package/{MultiplicityField/__stories__/PreviewDisplay.js → cjs/MultiplicityField/__stories__/PreviewDisplay/index.js} +4 -4
- package/{MultiplicityField/__stories__/WithExactLength.js → cjs/MultiplicityField/__stories__/WithExactLength/index.js} +6 -6
- package/{MultiplicityField/__stories__/WithMaxLength.js → cjs/MultiplicityField/__stories__/WithMaxLength/index.js} +6 -6
- package/{MultiplicityField/__stories__/WithMinAndMaxLength.js → cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js} +6 -6
- package/{MultiplicityField/__stories__/WithMinLength.js → cjs/MultiplicityField/__stories__/WithMinLength/index.js} +6 -6
- package/{MultiplicityField/add-objects.js → cjs/MultiplicityField/add-objects/index.js} +6 -6
- package/cjs/MultiplicityField/index.js +143 -0
- package/{Questions/Questions.js → cjs/Questions/Questions/index.js} +2 -2
- package/{Questions/Questions.stories.js → cjs/Questions/Questions.stories/index.js} +3 -3
- package/{Questions/Step/ReviewStep.js → cjs/Questions/Step/ReviewStep/index.js} +7 -7
- package/{Questions/Step/Step.js → cjs/Questions/Step/Step/index.js} +3 -3
- package/{Questions/Step/StepArrayReview.js → cjs/Questions/Step/StepArrayReview/index.js} +10 -10
- package/{Questions/Step/StepDescription.js → cjs/Questions/Step/StepDescription/index.js} +3 -3
- package/{Questions/Step/StepForm.js → cjs/Questions/Step/StepForm/index.js} +6 -6
- package/{Questions/Step/StepQuote.js → cjs/Questions/Step/StepQuote/index.js} +1 -1
- package/{Questions/Step/StepTitle.js → cjs/Questions/Step/StepTitle/index.js} +6 -6
- package/cjs/Questions/Step/index.js +170 -0
- package/{Questions/__stories__/Default.js → cjs/Questions/__stories__/Default/index.js} +19 -19
- package/cjs/Questions/index.js +25 -0
- package/{Questions/index.spec.js → cjs/Questions/index.spec/index.js} +9 -9
- package/cjs/index.js +28 -0
- package/{inputs/AutoComplete/AutoComplete.stories.js → cjs/inputs/AutoComplete/AutoComplete.stories/index.js} +3 -3
- package/{inputs/AutoComplete/__stories__/Default.js → cjs/inputs/AutoComplete/__stories__/Default/index.js} +4 -4
- package/cjs/inputs/AutoComplete/index.js +68 -0
- package/{inputs/Checkboxes/Checkboxes.stories.js → cjs/inputs/Checkboxes/Checkboxes.stories/index.js} +5 -5
- package/{inputs/Checkboxes/__stories__/Conditional.js → cjs/inputs/Checkboxes/__stories__/Conditional/index.js} +4 -4
- package/{inputs/Checkboxes/__stories__/Default.js → cjs/inputs/Checkboxes/__stories__/Default/index.js} +4 -4
- package/{inputs/Checkboxes/__stories__/WithDivider.js → cjs/inputs/Checkboxes/__stories__/WithDivider/index.js} +4 -4
- package/cjs/inputs/Checkboxes/index.js +127 -0
- package/{inputs/DateInput/DateInput.stories.js → cjs/inputs/DateInput/DateInput.stories/index.js} +3 -3
- package/{inputs/DateInput/__stories__/Default.js → cjs/inputs/DateInput/__stories__/Default/index.js} +4 -22
- package/cjs/inputs/DateInput/index.js +181 -0
- package/{inputs/FileInput/FileInput.stories.js → cjs/inputs/FileInput/FileInput.stories/index.js} +3 -3
- package/{inputs/FileInput/__stories__/Default.js → cjs/inputs/FileInput/__stories__/Default/index.js} +4 -4
- package/cjs/inputs/FileInput/index.js +92 -0
- package/cjs/inputs/ImageInput/ImageInput.stories/index.js +59 -0
- package/cjs/inputs/ImageInput/ImageInput.stories.playwright.json +77 -0
- package/cjs/inputs/ImageInput/__stories__/Default/index.js +51 -0
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +59 -0
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +56 -0
- package/cjs/inputs/ImageInput/index.js +116 -0
- package/{inputs/Input/Input.stories.js → cjs/inputs/Input/Input.stories/index.js} +11 -11
- package/{inputs/Input/__stories__/AFM.js → cjs/inputs/Input/__stories__/AFM/index.js} +4 -4
- package/{inputs/Input/__stories__/Boolean.js → cjs/inputs/Input/__stories__/Boolean/index.js} +4 -4
- package/{inputs/Input/__stories__/Default.js → cjs/inputs/Input/__stories__/Default/index.js} +4 -4
- package/{inputs/Input/__stories__/IBAN.js → cjs/inputs/Input/__stories__/IBAN/index.js} +4 -4
- package/{inputs/Input/__stories__/Integer.js → cjs/inputs/Input/__stories__/Integer/index.js} +5 -5
- package/{inputs/Input/__stories__/MobilePhone.js → cjs/inputs/Input/__stories__/MobilePhone/index.js} +4 -4
- package/{inputs/Input/__stories__/PhoneNumber.js → cjs/inputs/Input/__stories__/PhoneNumber/index.js} +4 -4
- package/{inputs/Input/__stories__/PostalCode.js → cjs/inputs/Input/__stories__/PostalCode/index.js} +4 -4
- package/{inputs/Input/__stories__/TextWithCharacterLimit.js → cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js} +5 -5
- package/cjs/inputs/Input/index.js +96 -0
- package/{inputs/Label/Label.stories.js → cjs/inputs/Label/Label.stories/index.js} +3 -3
- package/{inputs/Label/__stories__/Default.js → cjs/inputs/Label/__stories__/Default/index.js} +5 -5
- package/cjs/inputs/Label/index.js +41 -0
- package/{inputs/OtpInput/OtpInput.stories.js → cjs/inputs/OtpInput/OtpInput.stories/index.js} +3 -3
- package/{inputs/OtpInput/__stories__/Default.js → cjs/inputs/OtpInput/__stories__/Default/index.js} +5 -5
- package/cjs/inputs/OtpInput/index.js +182 -0
- package/{inputs/Radio/Radio.stories.js → cjs/inputs/Radio/Radio.stories/index.js} +5 -5
- package/{inputs/Radio/__stories__/Conditional.js → cjs/inputs/Radio/__stories__/Conditional/index.js} +4 -4
- package/{inputs/Radio/__stories__/Default.js → cjs/inputs/Radio/__stories__/Default/index.js} +5 -5
- package/{inputs/Radio/__stories__/WithDivider.js → cjs/inputs/Radio/__stories__/WithDivider/index.js} +5 -5
- package/cjs/inputs/Radio/index.js +82 -0
- package/{inputs/Select/Select.stories.js → cjs/inputs/Select/Select.stories/index.js} +3 -3
- package/{inputs/Select/__stories__/Default.js → cjs/inputs/Select/__stories__/Default/index.js} +5 -5
- package/cjs/inputs/Select/index.js +49 -0
- package/cjs/inputs/index.js +79 -0
- package/{internal.js → cjs/internal/index.js} +20 -20
- package/{registry.js → cjs/registry/index.js} +65 -59
- package/{es → cjs}/validators/index.js +63 -26
- package/{validators/utils/file.js → cjs/validators/utils/file/index.js} +4 -2
- package/{es/MultiplicityField/add-objects.js → cjs/validators/utils/image/index.js} +161 -153
- package/cjs/validators/utils/index.js +243 -0
- package/{validators/validators.spec.js → cjs/validators/validators.spec/index.js} +1 -1
- package/index.js +8 -28
- package/inputs/AutoComplete/AutoComplete.stories/index.js +7 -0
- package/inputs/AutoComplete/AutoComplete.stories/package.json +6 -0
- package/{es/inputs/AutoComplete/__stories__/Default.js → inputs/AutoComplete/__stories__/Default/index.js} +2 -2
- package/inputs/AutoComplete/__stories__/Default/package.json +6 -0
- package/inputs/AutoComplete/index.js +12 -35
- package/inputs/AutoComplete/package.json +6 -0
- package/inputs/Checkboxes/Checkboxes.stories/index.js +9 -0
- package/inputs/Checkboxes/Checkboxes.stories/package.json +6 -0
- package/{esm/inputs/Checkboxes/__stories__/Conditional.js → inputs/Checkboxes/__stories__/Conditional/index.js} +1 -1
- package/inputs/Checkboxes/__stories__/Conditional/package.json +6 -0
- package/{es/inputs/Checkboxes/__stories__/Default.js → inputs/Checkboxes/__stories__/Default/index.js} +1 -1
- package/inputs/Checkboxes/__stories__/Default/package.json +6 -0
- package/{es/inputs/Checkboxes/__stories__/WithDivider.js → inputs/Checkboxes/__stories__/WithDivider/index.js} +1 -1
- package/inputs/Checkboxes/__stories__/WithDivider/package.json +6 -0
- package/inputs/Checkboxes/index.js +25 -52
- package/inputs/Checkboxes/package.json +6 -0
- package/inputs/DateInput/DateInput.stories/index.js +7 -0
- package/inputs/DateInput/DateInput.stories/package.json +6 -0
- package/{esm/inputs/DateInput/__stories__/Default.js → inputs/DateInput/__stories__/Default/index.js} +1 -19
- package/inputs/DateInput/__stories__/Default/package.json +6 -0
- package/inputs/DateInput/index.js +26 -52
- package/inputs/DateInput/package.json +6 -0
- package/inputs/FileInput/FileInput.stories/index.js +7 -0
- package/inputs/FileInput/FileInput.stories/package.json +6 -0
- package/{esm/inputs/FileInput/__stories__/Default.js → inputs/FileInput/__stories__/Default/index.js} +1 -1
- package/inputs/FileInput/__stories__/Default/package.json +6 -0
- package/inputs/FileInput/index.d.ts +3 -1
- package/inputs/FileInput/index.js +22 -52
- package/inputs/FileInput/package.json +6 -0
- package/inputs/ImageInput/ImageInput.stories/index.js +9 -0
- package/inputs/ImageInput/ImageInput.stories/package.json +6 -0
- package/inputs/ImageInput/ImageInput.stories.d.ts +10 -0
- package/inputs/ImageInput/ImageInput.stories.playwright.json +77 -0
- package/{es/inputs/OtpInput/__stories__/Default.js → inputs/ImageInput/__stories__/Default/index.js} +4 -5
- package/inputs/ImageInput/__stories__/Default/package.json +6 -0
- package/inputs/ImageInput/__stories__/Default.d.ts +2 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +38 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +6 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +2 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +35 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +6 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +2 -0
- package/inputs/ImageInput/index.d.ts +25 -0
- package/inputs/ImageInput/index.js +83 -0
- package/inputs/ImageInput/package.json +6 -0
- package/inputs/Input/Input.stories/index.js +15 -0
- package/inputs/Input/Input.stories/package.json +6 -0
- package/{esm/inputs/Input/__stories__/AFM.js → inputs/Input/__stories__/AFM/index.js} +1 -1
- package/inputs/Input/__stories__/AFM/package.json +6 -0
- package/{esm/inputs/Input/__stories__/Boolean.js → inputs/Input/__stories__/Boolean/index.js} +1 -1
- package/inputs/Input/__stories__/Boolean/package.json +6 -0
- package/{esm/inputs/Input/__stories__/Default.js → inputs/Input/__stories__/Default/index.js} +1 -1
- package/inputs/Input/__stories__/Default/package.json +6 -0
- package/{esm/inputs/Input/__stories__/IBAN.js → inputs/Input/__stories__/IBAN/index.js} +1 -1
- package/inputs/Input/__stories__/IBAN/package.json +6 -0
- package/{es/inputs/Input/__stories__/Integer.js → inputs/Input/__stories__/Integer/index.js} +1 -1
- package/inputs/Input/__stories__/Integer/package.json +6 -0
- package/{esm/inputs/Input/__stories__/MobilePhone.js → inputs/Input/__stories__/MobilePhone/index.js} +1 -1
- package/inputs/Input/__stories__/MobilePhone/package.json +6 -0
- package/{es/inputs/Input/__stories__/PhoneNumber.js → inputs/Input/__stories__/PhoneNumber/index.js} +1 -1
- package/inputs/Input/__stories__/PhoneNumber/package.json +6 -0
- package/{esm/inputs/Input/__stories__/PostalCode.js → inputs/Input/__stories__/PostalCode/index.js} +1 -1
- package/inputs/Input/__stories__/PostalCode/package.json +6 -0
- package/{es/inputs/Input/__stories__/TextWithCharacterLimit.js → inputs/Input/__stories__/TextWithCharacterLimit/index.js} +1 -1
- package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +6 -0
- package/inputs/Input/index.js +19 -40
- package/inputs/Input/package.json +6 -0
- package/inputs/Label/Label.stories/index.js +7 -0
- package/inputs/Label/Label.stories/package.json +6 -0
- package/{esm/inputs/Label/__stories__/Default.js → inputs/Label/__stories__/Default/index.js} +1 -1
- package/inputs/Label/__stories__/Default/package.json +6 -0
- package/inputs/Label/index.js +9 -25
- package/inputs/Label/package.json +6 -0
- package/inputs/OtpInput/OtpInput.stories/index.js +7 -0
- package/inputs/OtpInput/OtpInput.stories/package.json +6 -0
- package/{esm/inputs/OtpInput/__stories__/Default.js → inputs/OtpInput/__stories__/Default/index.js} +1 -1
- package/inputs/OtpInput/__stories__/Default/package.json +6 -0
- package/inputs/OtpInput/index.js +28 -53
- package/inputs/OtpInput/package.json +6 -0
- package/inputs/Radio/Radio.stories/index.js +9 -0
- package/inputs/Radio/Radio.stories/package.json +6 -0
- package/{es/inputs/Radio/__stories__/Conditional.js → inputs/Radio/__stories__/Conditional/index.js} +1 -1
- package/inputs/Radio/__stories__/Conditional/package.json +6 -0
- package/{es/inputs/Radio/__stories__/Default.js → inputs/Radio/__stories__/Default/index.js} +2 -2
- package/inputs/Radio/__stories__/Default/package.json +6 -0
- package/{es/inputs/Radio/__stories__/WithDivider.js → inputs/Radio/__stories__/WithDivider/index.js} +2 -2
- package/inputs/Radio/__stories__/WithDivider/package.json +6 -0
- package/inputs/Radio/index.js +24 -45
- package/inputs/Radio/package.json +6 -0
- package/inputs/Select/Select.stories/index.js +7 -0
- package/inputs/Select/Select.stories/package.json +6 -0
- package/{esm/inputs/Select/__stories__/Default.js → inputs/Select/__stories__/Default/index.js} +2 -2
- package/inputs/Select/__stories__/Default/package.json +6 -0
- package/inputs/Select/index.js +12 -29
- package/inputs/Select/package.json +6 -0
- package/inputs/index.d.ts +1 -0
- package/inputs/index.js +9 -71
- package/inputs/package.json +6 -0
- package/internal/index.js +34 -0
- package/internal/package.json +6 -0
- package/package.json +6 -6
- package/{esm/registry.js → registry/index.js} +63 -59
- package/registry/package.json +6 -0
- package/registry.d.ts +2 -0
- package/src/Field/utils.ts +5 -0
- package/src/Questions/Step/index.ts +4 -4
- package/src/inputs/DateInput/__stories__/Default.tsx +0 -16
- package/src/inputs/FileInput/index.tsx +4 -1
- package/src/inputs/ImageInput/ImageInput.stories.js +10 -0
- package/src/inputs/ImageInput/ImageInput.stories.playwright.json +77 -0
- package/src/inputs/ImageInput/__stories__/Default.tsx +31 -0
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +40 -0
- package/src/inputs/ImageInput/__stories__/WithInvalidImageSize.tsx +36 -0
- package/src/inputs/ImageInput/index.tsx +101 -0
- package/src/inputs/Radio/__stories__/Default.tsx +1 -1
- package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
- package/src/inputs/Select/__stories__/Default.tsx +1 -1
- package/src/inputs/index.ts +1 -0
- package/src/registry.js +4 -0
- package/src/types.tsx +20 -18
- package/src/validators/index.ts +15 -1
- package/src/validators/utils/file.ts +2 -2
- package/src/validators/utils/image.ts +80 -0
- package/src/validators/utils/index.ts +1 -0
- package/types/package.json +6 -0
- package/types.d.ts +2 -1
- package/utils/package.json +6 -0
- package/validators/index.js +35 -54
- package/validators/package.json +6 -0
- package/validators/types/package.json +6 -0
- package/validators/utils/afm/package.json +6 -0
- package/{es/validators/utils/file.js → validators/utils/file/index.js} +4 -2
- package/validators/utils/file/package.json +6 -0
- package/validators/utils/iban/package.json +6 -0
- package/{esm/utils.js → validators/utils/image/index.js} +143 -87
- package/validators/utils/image/package.json +6 -0
- package/validators/utils/image.d.ts +3 -0
- package/validators/utils/index.d.ts +1 -0
- package/validators/utils/index.js +13 -139
- package/validators/utils/int/package.json +6 -0
- package/validators/utils/number/package.json +6 -0
- package/validators/utils/otp/package.json +6 -0
- package/validators/utils/package.json +6 -0
- package/validators/utils/phone/package.json +6 -0
- package/validators/utils/postal_code/package.json +6 -0
- package/validators/utils/text_limit/package.json +6 -0
- package/validators/utils/uuid4/package.json +6 -0
- package/{esm/validators/validators.spec.js → validators/validators.spec/index.js} +1 -1
- package/validators/validators.spec/package.json +6 -0
- package/es/Field/FieldBaseContainer.js +0 -43
- package/es/Field/index.js +0 -76
- package/es/FieldArray/FieldArray.stories.js +0 -8
- package/es/FieldArray/__stories__/Default.js +0 -90
- package/es/FieldArray/index.js +0 -65
- package/es/FieldObject/index.js +0 -58
- package/es/Fieldset/FieldsetWithContext.js +0 -41
- package/es/Fieldset/index.js +0 -34
- package/es/FormBuilder/FormBuilder.stories.js +0 -7
- package/es/FormBuilder/index.js +0 -2
- package/es/MultiplicityField/MultiplicityField.stories.js +0 -12
- package/es/MultiplicityField/__stories__/WithMinAndMaxLength.js +0 -96
- package/es/MultiplicityField/__stories__/WithMinLength.js +0 -95
- package/es/MultiplicityField/index.js +0 -114
- package/es/Questions/Questions.stories.js +0 -7
- package/es/Questions/Step/ReviewStep.js +0 -53
- package/es/Questions/Step/StepArrayReview.js +0 -50
- package/es/Questions/Step/StepDescription.js +0 -27
- package/es/Questions/Step/StepForm.js +0 -48
- package/es/Questions/Step/StepTitle.js +0 -44
- package/es/Questions/Step/index.js +0 -13
- package/es/Questions/index.js +0 -3
- package/es/Questions/index.spec.js +0 -62
- package/es/index.js +0 -3
- package/es/inputs/AutoComplete/AutoComplete.stories.js +0 -7
- package/es/inputs/AutoComplete/index.js +0 -45
- package/es/inputs/Checkboxes/Checkboxes.stories.js +0 -9
- package/es/inputs/Checkboxes/__stories__/Conditional.js +0 -95
- package/es/inputs/Checkboxes/index.js +0 -100
- package/es/inputs/DateInput/DateInput.stories.js +0 -7
- package/es/inputs/DateInput/__stories__/Default.js +0 -43
- package/es/inputs/DateInput/index.js +0 -155
- package/es/inputs/FileInput/FileInput.stories.js +0 -7
- package/es/inputs/FileInput/__stories__/Default.js +0 -22
- package/es/inputs/FileInput/index.js +0 -62
- package/es/inputs/Input/Input.stories.js +0 -15
- package/es/inputs/Input/__stories__/AFM.js +0 -24
- package/es/inputs/Input/__stories__/Boolean.js +0 -25
- package/es/inputs/Input/__stories__/Default.js +0 -25
- package/es/inputs/Input/__stories__/IBAN.js +0 -25
- package/es/inputs/Input/__stories__/MobilePhone.js +0 -24
- package/es/inputs/Input/__stories__/PostalCode.js +0 -27
- package/es/inputs/Input/index.js +0 -75
- package/es/inputs/Label/Label.stories.js +0 -7
- package/es/inputs/Label/__stories__/Default.js +0 -29
- package/es/inputs/Label/index.js +0 -25
- package/es/inputs/OtpInput/OtpInput.stories.js +0 -7
- package/es/inputs/OtpInput/index.js +0 -157
- package/es/inputs/Radio/Radio.stories.js +0 -9
- package/es/inputs/Radio/index.js +0 -61
- package/es/inputs/Select/Select.stories.js +0 -7
- package/es/inputs/Select/__stories__/Default.js +0 -53
- package/es/inputs/Select/index.js +0 -32
- package/es/inputs/index.js +0 -8
- package/es/internal.js +0 -34
- package/es/registry.js +0 -136
- package/es/validators/utils/index.js +0 -102
- package/es/validators/validators.spec.js +0 -85
- package/esm/Field/FieldBase.js +0 -84
- package/esm/Field/FieldConditional.js +0 -62
- package/esm/Field/index.js +0 -76
- package/esm/Field/index.mdx +0 -6
- package/esm/Field/types.js +0 -1
- package/esm/Field/utils.js +0 -162
- package/esm/FieldArray/FieldArray.stories.js +0 -8
- package/esm/FieldArray/FieldArray.stories.playwright.json +0 -353
- package/esm/FieldArray/__stories__/WithExactLength.js +0 -90
- package/esm/FieldArray/index.js +0 -65
- package/esm/FieldObject/index.js +0 -58
- package/esm/Fieldset/index.js +0 -34
- package/esm/Fieldset/types.js +0 -1
- package/esm/Form.stories.js +0 -3
- package/esm/FormBuilder/FormBuilder.js +0 -160
- package/esm/FormBuilder/FormBuilder.mdx +0 -256
- package/esm/FormBuilder/FormBuilder.stories.js +0 -7
- package/esm/FormBuilder/FormBuilder.stories.playwright.json +0 -52
- package/esm/FormBuilder/__stories__/Default.js +0 -28
- package/esm/FormBuilder/index.js +0 -2
- package/esm/FormContext.js +0 -5
- package/esm/MultiplicityField/MultiplicityField.mdx +0 -590
- package/esm/MultiplicityField/MultiplicityField.stories.js +0 -12
- package/esm/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
- package/esm/MultiplicityField/__stories__/Default.js +0 -97
- package/esm/MultiplicityField/__stories__/PreviewDisplay.js +0 -83
- package/esm/MultiplicityField/__stories__/WithExactLength.js +0 -92
- package/esm/MultiplicityField/__stories__/WithMaxLength.js +0 -95
- package/esm/MultiplicityField/index.js +0 -114
- package/esm/Questions/Questions.js +0 -84
- package/esm/Questions/Questions.stories.js +0 -7
- package/esm/Questions/QuestionsContext.js +0 -11
- package/esm/Questions/Step/Step.js +0 -69
- package/esm/Questions/Step/StepContext.js +0 -27
- package/esm/Questions/Step/StepQuote.js +0 -11
- package/esm/Questions/Step/getAddMoreFields.js +0 -22
- package/esm/Questions/Step/index.js +0 -13
- package/esm/Questions/Step/types.js +0 -1
- package/esm/Questions/__snapshots__/index.spec.tsx.snap +0 -596
- package/esm/Questions/__stories__/Default.js +0 -108
- package/esm/Questions/getNextStep.js +0 -23
- package/esm/Questions/index.js +0 -3
- package/esm/Questions/index.mdx +0 -415
- package/esm/Questions/types.js +0 -1
- package/esm/create-simple-form.mdx +0 -539
- package/esm/index.js +0 -8
- package/esm/index.mdx +0 -51
- package/esm/inputs/AutoComplete/AutoComplete.stories.js +0 -7
- package/esm/inputs/AutoComplete/__stories__/Default.js +0 -49
- package/esm/inputs/AutoComplete/index.js +0 -45
- package/esm/inputs/Checkboxes/Checkboxes.stories.js +0 -9
- package/esm/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
- package/esm/inputs/Checkboxes/__stories__/Default.js +0 -42
- package/esm/inputs/Checkboxes/__stories__/WithDivider.js +0 -43
- package/esm/inputs/Checkboxes/index.js +0 -100
- package/esm/inputs/Checkboxes/index.mdx +0 -0
- package/esm/inputs/DateInput/DateInput.stories.js +0 -7
- package/esm/inputs/DateInput/DateInput.stories.playwright.json +0 -72
- package/esm/inputs/DateInput/index.js +0 -155
- package/esm/inputs/FileInput/FileInput.stories.js +0 -7
- package/esm/inputs/FileInput/FileInput.stories.playwright.json +0 -75
- package/esm/inputs/FileInput/index.js +0 -62
- package/esm/inputs/Input/Input.stories.js +0 -15
- package/esm/inputs/Input/Input.stories.playwright.json +0 -376
- package/esm/inputs/Input/__stories__/Integer.js +0 -33
- package/esm/inputs/Input/__stories__/PhoneNumber.js +0 -24
- package/esm/inputs/Input/__stories__/TextWithCharacterLimit.js +0 -31
- package/esm/inputs/Input/index.js +0 -75
- package/esm/inputs/Input/index.mdx +0 -8
- package/esm/inputs/Label/Label.stories.js +0 -7
- package/esm/inputs/Label/Label.stories.playwright.json +0 -40
- package/esm/inputs/Label/index.js +0 -25
- package/esm/inputs/Label/index.mdx +0 -0
- package/esm/inputs/OtpInput/OtpInput.stories.js +0 -7
- package/esm/inputs/OtpInput/index.js +0 -157
- package/esm/inputs/Radio/Radio.stories.js +0 -9
- package/esm/inputs/Radio/Radio.stories.playwright.json +0 -73
- package/esm/inputs/Radio/__stories__/Conditional.js +0 -95
- package/esm/inputs/Radio/__stories__/Default.js +0 -47
- package/esm/inputs/Radio/__stories__/WithDivider.js +0 -48
- package/esm/inputs/Radio/index.js +0 -61
- package/esm/inputs/Radio/index.mdx +0 -0
- package/esm/inputs/Select/Select.stories.js +0 -7
- package/esm/inputs/Select/Select.stories.playwright.json +0 -22
- package/esm/inputs/Select/index.js +0 -32
- package/esm/inputs/index.js +0 -8
- package/esm/installation.mdx +0 -68
- package/esm/internal.js +0 -34
- package/esm/types.js +0 -1
- package/esm/validators/index.js +0 -186
- package/esm/validators/types.js +0 -1
- package/esm/validators/utils/afm.js +0 -35
- package/esm/validators/utils/file.js +0 -52
- package/esm/validators/utils/iban.js +0 -123
- package/esm/validators/utils/index.js +0 -102
- package/esm/validators/utils/int.js +0 -20
- package/esm/validators/utils/number.js +0 -16
- package/esm/validators/utils/otp.js +0 -26
- package/esm/validators/utils/phone.js +0 -122
- package/esm/validators/utils/postal_code.js +0 -29
- package/esm/validators/utils/text_limit.js +0 -54
- package/esm/validators/utils/uuid4.js +0 -20
- /package/{es/Field/types.js → Field/types/index.js} +0 -0
- /package/{es/Fieldset/types.js → Fieldset/types/index.js} +0 -0
- /package/{es/Form.stories.js → Form.stories/index.js} +0 -0
- /package/{es/FormContext.js → FormContext/index.js} +0 -0
- /package/{es/MultiplicityField/__stories__/PreviewDisplay.js → MultiplicityField/__stories__/PreviewDisplay/index.js} +0 -0
- /package/{es/Questions/QuestionsContext.js → Questions/QuestionsContext/index.js} +0 -0
- /package/{es/Questions/Step/StepContext.js → Questions/Step/StepContext/index.js} +0 -0
- /package/{es/Questions/Step/StepQuote.js → Questions/Step/StepQuote/index.js} +0 -0
- /package/{es/Questions/Step/getAddMoreFields.js → Questions/Step/getAddMoreFields/index.js} +0 -0
- /package/{es/Questions/Step/types.js → Questions/Step/types/index.js} +0 -0
- /package/{es/Questions/getNextStep.js → Questions/getNextStep/index.js} +0 -0
- /package/{es/Questions/types.js → Questions/types/index.js} +0 -0
- /package/{es → cjs}/Field/index.mdx +0 -0
- /package/{Field/types.js → cjs/Field/types/index.js} +0 -0
- /package/{es → cjs}/FieldArray/FieldArray.stories.playwright.json +0 -0
- /package/{Fieldset/types.js → cjs/Fieldset/types/index.js} +0 -0
- /package/{Form.stories.js → cjs/Form.stories/index.js} +0 -0
- /package/{es → cjs}/FormBuilder/FormBuilder.mdx +0 -0
- /package/{es → cjs}/FormBuilder/FormBuilder.stories.playwright.json +0 -0
- /package/{FormContext.js → cjs/FormContext/index.js} +0 -0
- /package/{es → cjs}/MultiplicityField/MultiplicityField.mdx +0 -0
- /package/{es → cjs}/MultiplicityField/MultiplicityField.stories.playwright.json +0 -0
- /package/{Questions/QuestionsContext.js → cjs/Questions/QuestionsContext/index.js} +0 -0
- /package/{Questions/Step/StepContext.js → cjs/Questions/Step/StepContext/index.js} +0 -0
- /package/{Questions/Step/getAddMoreFields.js → cjs/Questions/Step/getAddMoreFields/index.js} +0 -0
- /package/{Questions/Step/types.js → cjs/Questions/Step/types/index.js} +0 -0
- /package/{es → cjs}/Questions/__snapshots__/index.spec.tsx.snap +0 -0
- /package/{Questions/getNextStep.js → cjs/Questions/getNextStep/index.js} +0 -0
- /package/{es → cjs}/Questions/index.mdx +0 -0
- /package/{Questions/types.js → cjs/Questions/types/index.js} +0 -0
- /package/{es → cjs}/create-simple-form.mdx +0 -0
- /package/{es → cjs}/index.mdx +0 -0
- /package/{es → cjs}/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Checkboxes/index.mdx +0 -0
- /package/{es → cjs}/inputs/DateInput/DateInput.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/FileInput/FileInput.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Input/Input.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Input/index.mdx +0 -0
- /package/{es → cjs}/inputs/Label/Label.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Label/index.mdx +0 -0
- /package/{es → cjs}/inputs/Radio/Radio.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Radio/index.mdx +0 -0
- /package/{es → cjs}/inputs/Select/Select.stories.playwright.json +0 -0
- /package/{es → cjs}/installation.mdx +0 -0
- /package/{types.js → cjs/types/index.js} +0 -0
- /package/{utils.js → cjs/utils/index.js} +0 -0
- /package/{validators/types.js → cjs/validators/types/index.js} +0 -0
- /package/{validators/utils/afm.js → cjs/validators/utils/afm/index.js} +0 -0
- /package/{validators/utils/iban.js → cjs/validators/utils/iban/index.js} +0 -0
- /package/{validators/utils/int.js → cjs/validators/utils/int/index.js} +0 -0
- /package/{validators/utils/number.js → cjs/validators/utils/number/index.js} +0 -0
- /package/{validators/utils/otp.js → cjs/validators/utils/otp/index.js} +0 -0
- /package/{validators/utils/phone.js → cjs/validators/utils/phone/index.js} +0 -0
- /package/{validators/utils/postal_code.js → cjs/validators/utils/postal_code/index.js} +0 -0
- /package/{validators/utils/text_limit.js → cjs/validators/utils/text_limit/index.js} +0 -0
- /package/{validators/utils/uuid4.js → cjs/validators/utils/uuid4/index.js} +0 -0
- /package/{es/types.js → types/index.js} +0 -0
- /package/{es/utils.js → utils/index.js} +0 -0
- /package/{es/validators/types.js → validators/types/index.js} +0 -0
- /package/{es/validators/utils/afm.js → validators/utils/afm/index.js} +0 -0
- /package/{es/validators/utils/iban.js → validators/utils/iban/index.js} +0 -0
- /package/{es/validators/utils/int.js → validators/utils/int/index.js} +0 -0
- /package/{es/validators/utils/number.js → validators/utils/number/index.js} +0 -0
- /package/{es/validators/utils/otp.js → validators/utils/otp/index.js} +0 -0
- /package/{es/validators/utils/phone.js → validators/utils/phone/index.js} +0 -0
- /package/{es/validators/utils/postal_code.js → validators/utils/postal_code/index.js} +0 -0
- /package/{es/validators/utils/text_limit.js → validators/utils/text_limit/index.js} +0 -0
- /package/{es/validators/utils/uuid4.js → validators/utils/uuid4/index.js} +0 -0
package/esm/validators/index.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
|
-
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
-
import * as yup from 'yup';
|
|
6
|
-
import { getYupObjectShape, AFM_VALIDATOR, FILE_MAX_SIZE_VALIDATOR, IBAN_VALIDATOR, OTP_VALIDATOR, MOBILE_PHONE_VALIDATOR, PHONE_NUMBER_VALIDATOR, TEXT_LIMIT_VALIDATOR, POSTALCODE_VALIDATOR, UUID4_VALIDATOR } from '@digigov/form/validators/utils';
|
|
7
|
-
import { INT_VALIDATOR } from '@digigov/form/validators/utils/int';
|
|
8
|
-
import { NUMBER_VALIDATOR } from '@digigov/form/validators/utils/number';
|
|
9
|
-
dayjs.extend(customParseFormat);
|
|
10
|
-
var VALID_DATE_FORMATS = ['DD/MM/YYYY'];
|
|
11
|
-
var DATE_CACHE = {};
|
|
12
|
-
|
|
13
|
-
var getDate = function getDate(v) {
|
|
14
|
-
return DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export var getYUPTypeMap = function getYUPTypeMap() {
|
|
18
|
-
var yupTypeMap = {
|
|
19
|
-
file: function file(field) {
|
|
20
|
-
return yup.mixed().transform(function (value) {
|
|
21
|
-
if (!value.length) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return value;
|
|
26
|
-
}).nullable().test(FILE_MAX_SIZE_VALIDATOR(field));
|
|
27
|
-
},
|
|
28
|
-
string: yup.string,
|
|
29
|
-
"boolean": yup["boolean"],
|
|
30
|
-
object: function object(field) {
|
|
31
|
-
return getYupObjectShape(field.extra.fields, yupTypeMap);
|
|
32
|
-
},
|
|
33
|
-
array: function array(field) {
|
|
34
|
-
if (_typeof(field.extra.of) === 'object') {
|
|
35
|
-
// else if the field is an object then it is a scalar type
|
|
36
|
-
// eg. number, string etc.
|
|
37
|
-
var arrayValidator = yup.array().of(yupTypeMap[field.extra.of.type](field.extra.of)).required(field.required);
|
|
38
|
-
if (field.extra.length) arrayValidator = arrayValidator.length(field.extra.length, {
|
|
39
|
-
key: 'form.error.array.length',
|
|
40
|
-
context: {
|
|
41
|
-
length: field.extra.length
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
if (field.extra.min) arrayValidator = arrayValidator.min(field.extra.min, {
|
|
45
|
-
key: 'form.error.array.min',
|
|
46
|
-
context: {
|
|
47
|
-
min: field.extra.min
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
if (field.extra.max) arrayValidator = arrayValidator.max(field.extra.max, {
|
|
51
|
-
key: 'form.error.array.max',
|
|
52
|
-
context: {
|
|
53
|
-
max: field.extra.max
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return arrayValidator;
|
|
57
|
-
} else if (typeof field.extra.of === 'string') {
|
|
58
|
-
return yup.array().of(yupTypeMap[field.extra.of]());
|
|
59
|
-
} else {
|
|
60
|
-
// in any other case it will be string
|
|
61
|
-
return yup.array().of(yup.string());
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"int": function int() {
|
|
65
|
-
return yup.mixed().transform(function (_, val) {
|
|
66
|
-
return val !== '' ? Number(val) : null;
|
|
67
|
-
}).test(NUMBER_VALIDATOR()).test(INT_VALIDATOR());
|
|
68
|
-
},
|
|
69
|
-
email: function email() {
|
|
70
|
-
return yup.string().email('form.error.email');
|
|
71
|
-
},
|
|
72
|
-
afm: function afm() {
|
|
73
|
-
return yup.string().test(AFM_VALIDATOR);
|
|
74
|
-
},
|
|
75
|
-
uuid4: function uuid4() {
|
|
76
|
-
return yup.string().test(UUID4_VALIDATOR);
|
|
77
|
-
},
|
|
78
|
-
iban: function iban(field) {
|
|
79
|
-
return yup.string().test(IBAN_VALIDATOR(field));
|
|
80
|
-
},
|
|
81
|
-
otp: function otp(field) {
|
|
82
|
-
return yup.string().test(OTP_VALIDATOR(field));
|
|
83
|
-
},
|
|
84
|
-
text: function text(field) {
|
|
85
|
-
var _field$extra, _field$extra$limit, _field$extra2, _field$extra2$limit;
|
|
86
|
-
|
|
87
|
-
if (field !== null && field !== void 0 && (_field$extra = field.extra) !== null && _field$extra !== void 0 && (_field$extra$limit = _field$extra.limit) !== null && _field$extra$limit !== void 0 && _field$extra$limit.max || !!(field !== null && field !== void 0 && (_field$extra2 = field.extra) !== null && _field$extra2 !== void 0 && (_field$extra2$limit = _field$extra2.limit) !== null && _field$extra2$limit !== void 0 && _field$extra2$limit.min)) {
|
|
88
|
-
return yup.string().test(TEXT_LIMIT_VALIDATOR(field));
|
|
89
|
-
} else {
|
|
90
|
-
return yup.string();
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
postal_code: function postal_code(field) {
|
|
94
|
-
return yup.string().test(POSTALCODE_VALIDATOR(field));
|
|
95
|
-
},
|
|
96
|
-
mobile_phone: function mobile_phone() {
|
|
97
|
-
return yup.string().test(MOBILE_PHONE_VALIDATOR);
|
|
98
|
-
},
|
|
99
|
-
phone_number: function phone_number(field) {
|
|
100
|
-
return yup.string().test(PHONE_NUMBER_VALIDATOR(field));
|
|
101
|
-
},
|
|
102
|
-
'choice:multiple': function choiceMultiple() {
|
|
103
|
-
return yup.array().of(yup.string()).nullable();
|
|
104
|
-
},
|
|
105
|
-
'choice:single': function choiceSingle() {
|
|
106
|
-
return yup.string().nullable();
|
|
107
|
-
},
|
|
108
|
-
date: function date(field) {
|
|
109
|
-
var simpleDate = yup.string().nullable(true).test('date', 'form.error.date.invalid', function (value) {
|
|
110
|
-
if (!value) return true;
|
|
111
|
-
var date = getDate(value);
|
|
112
|
-
return date.isValid();
|
|
113
|
-
});
|
|
114
|
-
var params = field.extra || {};
|
|
115
|
-
|
|
116
|
-
if (params.max) {
|
|
117
|
-
var maxDate;
|
|
118
|
-
|
|
119
|
-
if (params.max === 'now') {
|
|
120
|
-
var today = new Date();
|
|
121
|
-
maxDate = new Date(today);
|
|
122
|
-
} else {
|
|
123
|
-
maxDate = getDate(params.max).toDate();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
var maxNextDate = new Date(maxDate);
|
|
127
|
-
maxNextDate.setDate(maxDate.getDate() + 1);
|
|
128
|
-
simpleDate = simpleDate.test({
|
|
129
|
-
name: 'earlier-than',
|
|
130
|
-
message: {
|
|
131
|
-
key: 'form.error.date.earlier_than',
|
|
132
|
-
context: {
|
|
133
|
-
maxDate: maxNextDate.toLocaleDateString()
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
test: function test(value) {
|
|
137
|
-
if (!value) return true;
|
|
138
|
-
var date = getDate(value);
|
|
139
|
-
var isValid = +date.toDate() < +maxDate;
|
|
140
|
-
return isValid;
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (params.min) {
|
|
146
|
-
var minDate;
|
|
147
|
-
|
|
148
|
-
if (params.min === 'now') {
|
|
149
|
-
var _today = new Date();
|
|
150
|
-
|
|
151
|
-
minDate = new Date(_today);
|
|
152
|
-
} else {
|
|
153
|
-
minDate = getDate(params.min).toDate();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
var minPreviousDate = new Date(minDate);
|
|
157
|
-
minPreviousDate.setDate(minDate.getDate() - 1);
|
|
158
|
-
simpleDate = simpleDate.test({
|
|
159
|
-
name: 'later-than',
|
|
160
|
-
message: {
|
|
161
|
-
key: 'form.error.date.later_than',
|
|
162
|
-
context: {
|
|
163
|
-
minDate: minPreviousDate.toLocaleDateString()
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
test: function test(value) {
|
|
167
|
-
if (!value) return true;
|
|
168
|
-
var date = getDate(value);
|
|
169
|
-
var isValid = +date.toDate() > +minDate;
|
|
170
|
-
return isValid;
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return simpleDate;
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
return yupTypeMap;
|
|
179
|
-
};
|
|
180
|
-
// Create a yup validation schema from given fields input
|
|
181
|
-
export function useValidationSchema(fields, validatorRegistry) {
|
|
182
|
-
return useMemo(function () {
|
|
183
|
-
var yupTypeMap = getYUPTypeMap();
|
|
184
|
-
return getYupObjectShape(fields, yupTypeMap, validatorRegistry);
|
|
185
|
-
}, []);
|
|
186
|
-
}
|
package/esm/validators/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export function validateAFM(afm) {
|
|
2
|
-
if (afm.length !== 9) {
|
|
3
|
-
// "afm should be 9 digits"
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
if (!/^\d+$/.test(afm)) {
|
|
8
|
-
// "This is not a number"
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (afm === '0'.repeat(9)) {
|
|
13
|
-
// "This is zero number (000000000)"
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var sum = afm.substring(0, 8).split('').reduce(function (s, v, i) {
|
|
18
|
-
return s + (parseInt(v) << 8 - i);
|
|
19
|
-
}, 0);
|
|
20
|
-
var calc = sum % 11;
|
|
21
|
-
var d9 = parseInt(afm[8]);
|
|
22
|
-
var valid = calc % 10 === d9;
|
|
23
|
-
return valid;
|
|
24
|
-
}
|
|
25
|
-
export var AFM_VALIDATOR = {
|
|
26
|
-
name: 'afm-validator',
|
|
27
|
-
message: 'form.error.afm',
|
|
28
|
-
test: function test(value) {
|
|
29
|
-
if (value) {
|
|
30
|
-
return validateAFM(value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
2
|
-
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
-
|
|
5
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
6
|
-
|
|
7
|
-
var DEFAULT_FILE_MAX_SIZE = 10000000;
|
|
8
|
-
export var FILE_MAX_SIZE_VALIDATOR = function FILE_MAX_SIZE_VALIDATOR(field) {
|
|
9
|
-
return {
|
|
10
|
-
name: 'file-max-size-validator',
|
|
11
|
-
message: 'form.error.file_size',
|
|
12
|
-
test: function test(value) {
|
|
13
|
-
if (field.extra && field.extra.maxSize && value) {
|
|
14
|
-
var _iterator = _createForOfIteratorHelper(value),
|
|
15
|
-
_step;
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
19
|
-
var file = _step.value;
|
|
20
|
-
|
|
21
|
-
if (file.size >= field.extra.maxSize) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
} catch (err) {
|
|
26
|
-
_iterator.e(err);
|
|
27
|
-
} finally {
|
|
28
|
-
_iterator.f();
|
|
29
|
-
}
|
|
30
|
-
} else if (value) {
|
|
31
|
-
var _iterator2 = _createForOfIteratorHelper(value),
|
|
32
|
-
_step2;
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
36
|
-
var _file = _step2.value;
|
|
37
|
-
|
|
38
|
-
if (_file.size >= DEFAULT_FILE_MAX_SIZE) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
} catch (err) {
|
|
43
|
-
_iterator2.e(err);
|
|
44
|
-
} finally {
|
|
45
|
-
_iterator2.f();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
export function validateIban(value, countryCode) {
|
|
2
|
-
value = value.replace(/\s/g, '').replace(/-/g, '');
|
|
3
|
-
|
|
4
|
-
if (value.match(/^[0-9]*$/i)) {
|
|
5
|
-
// this is for greek iban without the country code
|
|
6
|
-
if (value.length !== 25) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
} else {
|
|
10
|
-
value = value.toUpperCase();
|
|
11
|
-
|
|
12
|
-
if (countryCode) {
|
|
13
|
-
if (!value.startsWith(countryCode.toUpperCase())) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (value.length === ibanCountryCodesLengths[countryCode.toUpperCase()]) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (value.length !== 27) {
|
|
23
|
-
// this is for greek iban
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
export var IBAN_VALIDATOR = function IBAN_VALIDATOR(field) {
|
|
31
|
-
var _field$extra;
|
|
32
|
-
|
|
33
|
-
var countryCode = field === null || field === void 0 ? void 0 : (_field$extra = field.extra) === null || _field$extra === void 0 ? void 0 : _field$extra.country;
|
|
34
|
-
return {
|
|
35
|
-
name: 'iban-validator',
|
|
36
|
-
message: 'form.error.iban',
|
|
37
|
-
test: function test(value) {
|
|
38
|
-
if (!value) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return validateIban(value, countryCode);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
var ibanCountryCodesLengths = {
|
|
47
|
-
AD: 24,
|
|
48
|
-
AT: 20,
|
|
49
|
-
AZ: 28,
|
|
50
|
-
BH: 22,
|
|
51
|
-
BY: 28,
|
|
52
|
-
BE: 16,
|
|
53
|
-
BA: 20,
|
|
54
|
-
BR: 29,
|
|
55
|
-
BG: 22,
|
|
56
|
-
CR: 22,
|
|
57
|
-
HR: 21,
|
|
58
|
-
CY: 28,
|
|
59
|
-
CZ: 24,
|
|
60
|
-
DK: 18,
|
|
61
|
-
DO: 28,
|
|
62
|
-
EG: 29,
|
|
63
|
-
SV: 28,
|
|
64
|
-
EE: 20,
|
|
65
|
-
FO: 18,
|
|
66
|
-
FI: 18,
|
|
67
|
-
FR: 27,
|
|
68
|
-
GE: 22,
|
|
69
|
-
DE: 22,
|
|
70
|
-
GI: 23,
|
|
71
|
-
GR: 27,
|
|
72
|
-
GL: 18,
|
|
73
|
-
GT: 28,
|
|
74
|
-
VA: 22,
|
|
75
|
-
HU: 28,
|
|
76
|
-
IS: 26,
|
|
77
|
-
IQ: 23,
|
|
78
|
-
IE: 22,
|
|
79
|
-
IL: 23,
|
|
80
|
-
IT: 27,
|
|
81
|
-
JO: 30,
|
|
82
|
-
KZ: 20,
|
|
83
|
-
XK: 20,
|
|
84
|
-
KW: 30,
|
|
85
|
-
LV: 21,
|
|
86
|
-
LB: 28,
|
|
87
|
-
LI: 21,
|
|
88
|
-
LT: 20,
|
|
89
|
-
LU: 20,
|
|
90
|
-
MT: 31,
|
|
91
|
-
MR: 27,
|
|
92
|
-
MU: 30,
|
|
93
|
-
MD: 24,
|
|
94
|
-
MC: 27,
|
|
95
|
-
ME: 22,
|
|
96
|
-
NL: 18,
|
|
97
|
-
MK: 19,
|
|
98
|
-
NO: 15,
|
|
99
|
-
PK: 24,
|
|
100
|
-
PS: 29,
|
|
101
|
-
PL: 28,
|
|
102
|
-
PT: 25,
|
|
103
|
-
QA: 29,
|
|
104
|
-
RO: 24,
|
|
105
|
-
LC: 32,
|
|
106
|
-
SM: 27,
|
|
107
|
-
ST: 25,
|
|
108
|
-
SA: 24,
|
|
109
|
-
RS: 22,
|
|
110
|
-
SC: 31,
|
|
111
|
-
SK: 24,
|
|
112
|
-
SI: 19,
|
|
113
|
-
ES: 24,
|
|
114
|
-
SE: 24,
|
|
115
|
-
CH: 21,
|
|
116
|
-
TL: 23,
|
|
117
|
-
TN: 24,
|
|
118
|
-
TR: 26,
|
|
119
|
-
UA: 29,
|
|
120
|
-
AE: 23,
|
|
121
|
-
GB: 22,
|
|
122
|
-
VG: 24
|
|
123
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import * as yup from 'yup';
|
|
2
|
-
export * from '@digigov/form/validators/utils/afm';
|
|
3
|
-
export * from '@digigov/form/validators/utils/file';
|
|
4
|
-
export * from '@digigov/form/validators/utils/iban';
|
|
5
|
-
export * from '@digigov/form/validators/utils/otp';
|
|
6
|
-
export * from '@digigov/form/validators/utils/phone';
|
|
7
|
-
export * from '@digigov/form/validators/utils/postal_code';
|
|
8
|
-
export * from '@digigov/form/validators/utils/uuid4';
|
|
9
|
-
export * from '@digigov/form/validators/utils/text_limit';
|
|
10
|
-
export function getYupField(field, yupTypeMap) {
|
|
11
|
-
var yupField = yupTypeMap[(field === null || field === void 0 ? void 0 : field.type) || 'string'] || yupTypeMap['string'];
|
|
12
|
-
return yupField(field);
|
|
13
|
-
}
|
|
14
|
-
export function computeShape(fields, yupTypeMap, validatorRegistry) {
|
|
15
|
-
var fieldSchemas = {};
|
|
16
|
-
var objectFields = {};
|
|
17
|
-
fields.forEach(function (field) {
|
|
18
|
-
var yupField = getYupField(field, yupTypeMap);
|
|
19
|
-
|
|
20
|
-
if (field.condition) {
|
|
21
|
-
var _loop = function _loop(key) {
|
|
22
|
-
var then = void 0,
|
|
23
|
-
otherwise = void 0;
|
|
24
|
-
|
|
25
|
-
if (field.condition[key].then) {
|
|
26
|
-
var _field$condition$key$, _field$condition$key$2;
|
|
27
|
-
|
|
28
|
-
if (((_field$condition$key$ = field.condition[key].then) === null || _field$condition$key$ === void 0 ? void 0 : _field$condition$key$.required) === false) {
|
|
29
|
-
then = yupField.nullable();
|
|
30
|
-
} else if (((_field$condition$key$2 = field.condition[key].then) === null || _field$condition$key$2 === void 0 ? void 0 : _field$condition$key$2.required) === true) {
|
|
31
|
-
then = yupField.nullable().required('form.error.required');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (field.condition[key]["else"]) {
|
|
36
|
-
var _field$condition$key$3, _field$condition$key$4;
|
|
37
|
-
|
|
38
|
-
if (((_field$condition$key$3 = field.condition[key]["else"]) === null || _field$condition$key$3 === void 0 ? void 0 : _field$condition$key$3.required) === false) {
|
|
39
|
-
otherwise = yupField.nullable();
|
|
40
|
-
} else if (((_field$condition$key$4 = field.condition[key]["else"]) === null || _field$condition$key$4 === void 0 ? void 0 : _field$condition$key$4.required) === true) {
|
|
41
|
-
otherwise = yupField.nullable().required('form.error.required');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (then || otherwise) {
|
|
46
|
-
yupField = yupField.when(key, {
|
|
47
|
-
is: function is(val) {
|
|
48
|
-
//@ts-ignore
|
|
49
|
-
var is = field.condition[key].is;
|
|
50
|
-
|
|
51
|
-
if (is === val || Array.isArray(val) && val.includes(is)) {
|
|
52
|
-
return true;
|
|
53
|
-
} else {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
then: then,
|
|
58
|
-
otherwise: otherwise
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
for (var key in field.condition) {
|
|
64
|
-
_loop(key);
|
|
65
|
-
}
|
|
66
|
-
} else if (field.required) {
|
|
67
|
-
yupField = yupField.nullable().required('form.error.required');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (validatorRegistry && field.type && validatorRegistry[field.type]) {
|
|
71
|
-
validatorRegistry[field.type].forEach(function (validator) {
|
|
72
|
-
yupField = yupField.test(validator);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (field.validators) {
|
|
77
|
-
field.validators.forEach(function (validator) {
|
|
78
|
-
yupField = yupField.test(validator);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
fieldSchemas[field.key] = yupField;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
for (var objectKey in objectFields) {
|
|
86
|
-
fieldSchemas[objectKey] = getYupObjectShape(objectFields[objectKey], yupTypeMap, validatorRegistry);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return fieldSchemas;
|
|
90
|
-
}
|
|
91
|
-
export function getYupObjectShape( // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
-
fields, yupTypeMap, validatorRegistry) {
|
|
93
|
-
if (!fields.current) {
|
|
94
|
-
var fieldSchemas = computeShape(fields, yupTypeMap, validatorRegistry);
|
|
95
|
-
return yup.object().shape(fieldSchemas);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return yup.lazy(function () {
|
|
99
|
-
var fieldSchemas = computeShape(Object.values(fields.current), yupTypeMap, validatorRegistry);
|
|
100
|
-
return yup.object().shape(fieldSchemas);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function validateIntNumber(number) {
|
|
2
|
-
if (number === undefined) {
|
|
3
|
-
return false;
|
|
4
|
-
} else {
|
|
5
|
-
return Number.isInteger(number) && Number(number) > 0;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export var INT_VALIDATOR = function INT_VALIDATOR() {
|
|
9
|
-
return {
|
|
10
|
-
name: 'int-validator',
|
|
11
|
-
message: 'form.error.positive_integer_number',
|
|
12
|
-
test: function test(value) {
|
|
13
|
-
if (value === null) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return validateIntNumber(value);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function validateNumber(number) {
|
|
2
|
-
return !Number.isNaN(number);
|
|
3
|
-
}
|
|
4
|
-
export var NUMBER_VALIDATOR = function NUMBER_VALIDATOR() {
|
|
5
|
-
return {
|
|
6
|
-
name: 'number-validator',
|
|
7
|
-
message: 'form.error.number',
|
|
8
|
-
test: function test(value) {
|
|
9
|
-
if (value === null) {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return validateNumber(value);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export function validateOtp(value, maxLength) {
|
|
2
|
-
if (value.length === maxLength) {
|
|
3
|
-
return true;
|
|
4
|
-
} else {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export var OTP_VALIDATOR = function OTP_VALIDATOR(field) {
|
|
9
|
-
var maxLength = field === null || field === void 0 ? void 0 : field.maxLength;
|
|
10
|
-
return {
|
|
11
|
-
name: 'otp-validator',
|
|
12
|
-
message: {
|
|
13
|
-
key: 'form.error.otp.less_than',
|
|
14
|
-
context: {
|
|
15
|
-
maxLength: field === null || field === void 0 ? void 0 : field.maxLength
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
test: function test(value) {
|
|
19
|
-
if (!value) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return validateOtp(value, maxLength);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as gPhoneNumber from 'google-libphonenumber';
|
|
2
|
-
export function validatePhoneNumber(phoneNumber) {
|
|
3
|
-
var countries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['gr'];
|
|
4
|
-
var typeOfPhoneNumber = arguments.length > 2 ? arguments[2] : undefined;
|
|
5
|
-
var phoneUtil = gPhoneNumber.PhoneNumberUtil.getInstance();
|
|
6
|
-
|
|
7
|
-
if (!countries || countries.length === 0) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return countries.some(function (country) {
|
|
12
|
-
try {
|
|
13
|
-
var phone = phoneUtil.parse(phoneNumber, country.toUpperCase());
|
|
14
|
-
|
|
15
|
-
if (phoneUtil.isValidNumber(phone)) {
|
|
16
|
-
if (typeOfPhoneNumber) {
|
|
17
|
-
if (matchTypeOfPhoneNumber(phone, typeOfPhoneNumber, phoneUtil)) {
|
|
18
|
-
return true;
|
|
19
|
-
} else {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return false;
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.error(error);
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
var phoneNumberTypes = {
|
|
35
|
-
0: 'landline',
|
|
36
|
-
1: 'mobile',
|
|
37
|
-
2: 'landline_or_mobile'
|
|
38
|
-
};
|
|
39
|
-
export function matchTypeOfPhoneNumber(phone, type, phoneUtil) {
|
|
40
|
-
try {
|
|
41
|
-
var phoneNumberType = phoneUtil.getNumberType(phone);
|
|
42
|
-
var numberType = phoneNumberTypes[phoneNumberType];
|
|
43
|
-
|
|
44
|
-
if (numberType === 'landline_or_mobile' || numberType === type) {
|
|
45
|
-
return true;
|
|
46
|
-
} else {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error(error);
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function validateMobile(value) {
|
|
56
|
-
var phoneUtil = gPhoneNumber.PhoneNumberUtil.getInstance();
|
|
57
|
-
var origValue = value; // probably catch all the cases with a regex instead of gphonenumber
|
|
58
|
-
|
|
59
|
-
if (!value.match(/^((\+|00){0,1}\d{1,3}[- ]?)?\d{10}$/)) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
var phone;
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
phone = phoneUtil.parse(value);
|
|
68
|
-
} catch (err) {
|
|
69
|
-
try {
|
|
70
|
-
value = '+' + value;
|
|
71
|
-
phone = phoneUtil.parse(value);
|
|
72
|
-
} catch (err) {
|
|
73
|
-
value = '+30' + origValue;
|
|
74
|
-
phone = phoneUtil.parse(value);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return phoneUtil.isValidNumber(phone);
|
|
79
|
-
} catch (err) {
|
|
80
|
-
console.error(err);
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export var MOBILE_PHONE_VALIDATOR = {
|
|
86
|
-
name: 'mobile-phone-validator',
|
|
87
|
-
message: 'form.error.mobile_phone',
|
|
88
|
-
test: function test(value) {
|
|
89
|
-
if (value) {
|
|
90
|
-
return validateMobile(value);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
export var PHONE_NUMBER_VALIDATOR = function PHONE_NUMBER_VALIDATOR(field) {
|
|
97
|
-
var _field$extra, _field$extra2;
|
|
98
|
-
|
|
99
|
-
var countryCode = field === null || field === void 0 ? void 0 : (_field$extra = field.extra) === null || _field$extra === void 0 ? void 0 : _field$extra.countries;
|
|
100
|
-
var typeOfPhone = field === null || field === void 0 ? void 0 : (_field$extra2 = field.extra) === null || _field$extra2 === void 0 ? void 0 : _field$extra2.phoneType;
|
|
101
|
-
return {
|
|
102
|
-
name: 'phone-number-validator',
|
|
103
|
-
message: function message() {
|
|
104
|
-
if (typeOfPhone === 'mobile') {
|
|
105
|
-
return 'form.error.mobile_phone';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (typeOfPhone === 'landline') {
|
|
109
|
-
return 'form.error.landline';
|
|
110
|
-
} else {
|
|
111
|
-
return 'form.error.phone_number';
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
test: function test(value) {
|
|
115
|
-
if (!value) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return validatePhoneNumber(value, countryCode, typeOfPhone);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
};
|