@globalpayments/vega 2.39.0 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{app-globals-dd3e7925.js → app-globals-cdd0972c.js} +12 -1
- package/dist/cjs/check-box-required-rule-1ee54b9a.js +70 -0
- package/dist/cjs/date-required-rule-4e1f84fd.js +92 -0
- package/dist/cjs/{element-appender-slimmer-c6e0f4ca.js → element-appender-slimmer-4f0dc8c6.js} +9 -5
- package/dist/cjs/file-uploader-required-rule-313ec9e3.js +21 -0
- package/dist/cjs/{form-field-controller-slimmer-48c0ad0b.js → form-field-controller-slimmer-d92e8212.js} +28 -1
- package/dist/cjs/index.cjs.js +22 -1
- package/dist/cjs/input-phone-number-required-rule-2668fdf1.js +65 -0
- package/dist/cjs/input-range-required-rule-5b9c2a95.js +63 -0
- package/dist/cjs/internal-form-field-validation-rule.abstract-07cdff46.js +15 -0
- package/dist/cjs/loader.cjs.js +3 -2
- package/dist/cjs/{min-number-rule-115c5a3b.js → min-number-rule-5bcccc8f.js} +7 -4
- package/dist/cjs/{min-string-length-rule-75f24a48.js → min-string-length-rule-af215976.js} +8 -4
- package/dist/cjs/public-rules-90b972e5.js +42 -0
- package/dist/cjs/{required-field-rule-7f9945fa.js → required-field-rule-d73c1d8c.js} +6 -3
- package/dist/cjs/rich-text-editor-required-rule-cacc5fe0.js +64 -0
- package/dist/cjs/time-required-rule-ccf178e7.js +141 -0
- package/dist/cjs/toggle-switch-required-rule-88a51b36.js +66 -0
- package/dist/cjs/{valid-credit-card-number-rule-4a9ae5d9.js → valid-credit-card-number-rule-4a1b00b8.js} +3 -2
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +11 -79
- package/dist/cjs/vega-color-picker.cjs.entry.js +3 -2
- package/dist/cjs/vega-combo-box.cjs.entry.js +3 -2
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +8 -90
- package/dist/cjs/vega-dialog_2.cjs.entry.js +29 -1
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +1 -1
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-file-uploader.cjs.entry.js +5 -19
- package/dist/cjs/vega-form.cjs.entry.js +2 -1
- package/dist/cjs/vega-image-uploader.cjs.entry.js +3 -2
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +4 -3
- package/dist/cjs/vega-input-numeric.cjs.entry.js +3 -2
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +7 -63
- package/dist/cjs/vega-input-range.cjs.entry.js +6 -61
- package/dist/cjs/vega-input-select.cjs.entry.js +3 -2
- package/dist/cjs/vega-input.cjs.entry.js +7 -6
- package/dist/cjs/vega-popover_2.cjs.entry.js +1 -1
- package/dist/cjs/vega-radio_2.cjs.entry.js +3 -2
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +4 -60
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +3 -2
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +3 -2
- package/dist/cjs/vega-signature-capture.cjs.entry.js +3 -2
- package/dist/cjs/vega-stepper.cjs.entry.js +3 -2
- package/dist/cjs/vega-textarea.cjs.entry.js +4 -3
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +11 -140
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +4 -63
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +53 -12
- package/dist/cjs/vega.cjs.js +3 -2
- package/dist/collection/components/vega-checkbox/vega-checkbox.css +82 -33
- package/dist/collection/components/vega-checkbox/vega-checkbox.js +8 -13
- package/dist/collection/components/vega-file-uploader/vega-file-uploader.js +2 -2
- package/dist/collection/components/vega-modal/slimmers/controllers/vega-modal-layout-controller.js +9 -0
- package/dist/collection/components/vega-modal/slimmers/controllers/vega-modal-scroll-controller.js +16 -0
- package/dist/collection/components/vega-modal/vega-modal.js +6 -0
- package/dist/collection/components/vega-tooltip/slimmers/controllers/vega-tooltip-element-appender-controller.js +45 -11
- package/dist/collection/components/vega-tooltip/vega-tooltip.js +12 -0
- package/dist/collection/global/scripts/before-vega-load.js +11 -0
- package/dist/collection/helpers/slimmers/element-appender-slimmer.js +8 -5
- package/dist/collection/helpers/slimmers/test/element-appender-slimmer.test.js +2 -0
- package/dist/collection/helpers/ui/element-appender.js +1 -0
- package/dist/collection/helpers/ui/test/element-appender.test.js +1 -0
- package/dist/collection/helpers/validator/form-field-controller.js +28 -1
- package/dist/collection/helpers/validator/public-rules.js +10 -0
- package/dist/collection/helpers/validator/rules/check-box-required-rule.js +4 -3
- package/dist/collection/helpers/validator/rules/date-range-rule.js +2 -1
- package/dist/collection/helpers/validator/rules/date-required-rule.js +5 -3
- package/dist/collection/helpers/validator/rules/email-field-rule.js +3 -2
- package/dist/collection/helpers/validator/rules/{object-array-required-rule.js → file-uploader-required-rule.js} +1 -1
- package/dist/collection/helpers/validator/rules/input-phone-number-required-rule.js +5 -3
- package/dist/collection/helpers/validator/rules/input-range-min-and-max-rule.js +3 -1
- package/dist/collection/helpers/validator/rules/input-range-required-rule.js +5 -4
- package/dist/collection/helpers/validator/rules/internal-form-field-validation-rule.abstract.js +11 -0
- package/dist/collection/helpers/validator/rules/max-number-rule.js +4 -2
- package/dist/collection/helpers/validator/rules/max-string-length-rule.js +4 -2
- package/dist/collection/helpers/validator/rules/min-and-max-date-rule.js +3 -1
- package/dist/collection/helpers/validator/rules/min-number-rule.js +4 -2
- package/dist/collection/helpers/validator/rules/min-string-length-rule.js +4 -2
- package/dist/collection/helpers/validator/rules/required-field-rule.js +5 -3
- package/dist/collection/helpers/validator/rules/rich-text-editor-required-rule.js +4 -3
- package/dist/collection/helpers/validator/rules/time-range-required-rule.js +5 -3
- package/dist/collection/helpers/validator/rules/time-range-rule.js +3 -1
- package/dist/collection/helpers/validator/rules/time-required-rule.js +5 -3
- package/dist/collection/helpers/validator/rules/toggle-switch-required-rule.js +4 -3
- package/dist/collection/helpers/validator/rules/valid-credit-card-number-rule.js +3 -2
- package/dist/collection/helpers/validator/rules/valid-phone-number-rule.js +4 -2
- package/dist/collection/helpers/validator/test/rules/file-uploader-required-rule.test.js +7 -0
- package/dist/collection/helpers/validator/test/rules/public-rules.test.js +80 -0
- package/dist/collection/index.js +1 -0
- package/dist/esm/{app-globals-c954167a.js → app-globals-88fa3549.js} +12 -1
- package/dist/esm/check-box-required-rule-cb0aa339.js +68 -0
- package/dist/esm/{date-732bc749.js → date-c55b97f0.js} +1 -1
- package/dist/esm/date-required-rule-8944f3bf.js +90 -0
- package/dist/esm/{element-appender-slimmer-f5e703f3.js → element-appender-slimmer-d9155ee0.js} +9 -5
- package/dist/esm/file-uploader-required-rule-ad886d01.js +19 -0
- package/dist/esm/{form-field-controller-slimmer-7a9f2b2e.js → form-field-controller-slimmer-bb64dec7.js} +28 -1
- package/dist/esm/index.js +12 -1
- package/dist/esm/input-phone-number-required-rule-be6a5572.js +63 -0
- package/dist/esm/input-range-required-rule-3ad74776.js +61 -0
- package/dist/esm/internal-form-field-validation-rule.abstract-f5b6bdbf.js +13 -0
- package/dist/esm/loader.js +3 -2
- package/dist/esm/{min-number-rule-31d48b22.js → min-number-rule-a6082418.js} +7 -4
- package/dist/esm/{min-string-length-rule-c6a69eeb.js → min-string-length-rule-c31c89f4.js} +8 -4
- package/dist/esm/public-rules-413f6a17.js +27 -0
- package/dist/esm/{required-field-rule-368b31fa.js → required-field-rule-ab4bdc47.js} +6 -3
- package/dist/esm/rich-text-editor-required-rule-75cc2db0.js +62 -0
- package/dist/esm/time-required-rule-a01163b5.js +138 -0
- package/dist/esm/toggle-switch-required-rule-b3cf4302.js +64 -0
- package/dist/esm/{valid-credit-card-number-rule-2aef3ad5.js → valid-credit-card-number-rule-cc497bec.js} +3 -2
- package/dist/esm/vega-calendar_3.entry.js +1 -1
- package/dist/esm/vega-checkbox_2.entry.js +11 -79
- package/dist/esm/vega-color-picker.entry.js +3 -2
- package/dist/esm/vega-combo-box.entry.js +3 -2
- package/dist/esm/vega-date-picker_2.entry.js +8 -90
- package/dist/esm/vega-dialog_2.entry.js +29 -1
- package/dist/esm/vega-dropdown_5.entry.js +1 -1
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-file-uploader.entry.js +5 -19
- package/dist/esm/vega-form.entry.js +2 -1
- package/dist/esm/vega-image-uploader.entry.js +3 -2
- package/dist/esm/vega-input-credit-card.entry.js +4 -3
- package/dist/esm/vega-input-numeric.entry.js +3 -2
- package/dist/esm/vega-input-phone-number.entry.js +6 -62
- package/dist/esm/vega-input-range.entry.js +5 -60
- package/dist/esm/vega-input-select.entry.js +3 -2
- package/dist/esm/vega-input.entry.js +7 -6
- package/dist/esm/vega-popover_2.entry.js +1 -1
- package/dist/esm/vega-radio_2.entry.js +3 -2
- package/dist/esm/vega-rich-text-editor_4.entry.js +3 -59
- package/dist/esm/vega-selection-chip_2.entry.js +3 -2
- package/dist/esm/vega-selection-tile_2.entry.js +3 -2
- package/dist/esm/vega-signature-capture.entry.js +3 -2
- package/dist/esm/vega-stepper.entry.js +3 -2
- package/dist/esm/vega-textarea.entry.js +4 -3
- package/dist/esm/vega-time-picker_2.entry.js +7 -136
- package/dist/esm/vega-toggle-switch.entry.js +3 -62
- package/dist/esm/vega-tooltip_2.entry.js +53 -12
- package/dist/esm/vega.js +3 -2
- package/dist/types/components/vega-modal/slimmers/controllers/vega-modal-layout-controller.d.ts +4 -0
- package/dist/types/components/vega-modal/slimmers/controllers/vega-modal-scroll-controller.d.ts +5 -0
- package/dist/types/components/vega-modal/vega-modal.d.ts +1 -0
- package/dist/types/components/vega-tooltip/slimmers/controllers/vega-tooltip-element-appender-controller.d.ts +18 -0
- package/dist/types/components/vega-tooltip/vega-tooltip.d.ts +4 -0
- package/dist/types/helpers/slimmers/element-appender-slimmer.d.ts +1 -0
- package/dist/types/helpers/slimmers/form-field-controller-slimmer.d.ts +2 -1
- package/dist/types/helpers/validator/form-field-controller.d.ts +10 -0
- package/dist/types/helpers/validator/public-rules.d.ts +10 -0
- package/dist/types/helpers/validator/rules/check-box-required-rule.d.ts +7 -6
- package/dist/types/helpers/validator/rules/date-range-rule.d.ts +3 -2
- package/dist/types/helpers/validator/rules/date-required-rule.d.ts +7 -6
- package/dist/types/helpers/validator/rules/email-field-rule.d.ts +4 -3
- package/dist/types/helpers/validator/rules/{object-array-required-rule.d.ts → file-uploader-required-rule.d.ts} +1 -1
- package/dist/types/helpers/validator/rules/input-phone-number-required-rule.d.ts +7 -6
- package/dist/types/helpers/validator/rules/input-range-min-and-max-rule.d.ts +3 -2
- package/dist/types/helpers/validator/rules/input-range-required-rule.d.ts +8 -7
- package/dist/types/helpers/validator/rules/internal-form-field-validation-rule.abstract.d.ts +19 -0
- package/dist/types/helpers/validator/rules/max-number-rule.d.ts +4 -3
- package/dist/types/helpers/validator/rules/max-string-length-rule.d.ts +4 -3
- package/dist/types/helpers/validator/rules/min-and-max-date-rule.d.ts +3 -2
- package/dist/types/helpers/validator/rules/min-number-rule.d.ts +4 -3
- package/dist/types/helpers/validator/rules/min-string-length-rule.d.ts +4 -3
- package/dist/types/helpers/validator/rules/required-field-rule.d.ts +7 -6
- package/dist/types/helpers/validator/rules/rich-text-editor-required-rule.d.ts +7 -6
- package/dist/types/helpers/validator/rules/time-range-required-rule.d.ts +7 -6
- package/dist/types/helpers/validator/rules/time-range-rule.d.ts +3 -2
- package/dist/types/helpers/validator/rules/time-required-rule.d.ts +7 -6
- package/dist/types/helpers/validator/rules/toggle-switch-required-rule.d.ts +5 -4
- package/dist/types/helpers/validator/rules/valid-credit-card-number-rule.d.ts +4 -3
- package/dist/types/helpers/validator/rules/valid-phone-number-rule.d.ts +4 -3
- package/dist/types/helpers/validator/test/rules/public-rules.test.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types/public-api.d.ts +1 -1
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/p-04c72f30.entry.js +1 -0
- package/dist/vega/p-07c2725a.js +1 -0
- package/dist/vega/{p-b5990090.js → p-08835909.js} +1 -1
- package/dist/vega/p-0b6d4561.entry.js +1 -0
- package/dist/vega/p-0bb860cc.js +1 -0
- package/dist/vega/p-113cd659.entry.js +1 -0
- package/dist/vega/{p-64e49394.entry.js → p-154d262e.entry.js} +1 -1
- package/dist/vega/p-17598aac.entry.js +1 -0
- package/dist/vega/p-23130825.entry.js +1 -0
- package/dist/vega/p-280cbcdb.js +1 -0
- package/dist/vega/{p-4b19706c.entry.js → p-3299c30b.entry.js} +1 -1
- package/dist/vega/p-3fd9d39f.entry.js +1 -0
- package/dist/vega/p-42a949f5.entry.js +1 -0
- package/dist/vega/p-4bd1b877.entry.js +1 -0
- package/dist/vega/p-590fd123.js +1 -0
- package/dist/vega/{p-d2e6090a.js → p-5a7eabcc.js} +1 -1
- package/dist/vega/p-5e56f3bd.js +1 -0
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/p-612c9374.entry.js +1 -0
- package/dist/vega/{p-9ee23f34.entry.js → p-6585bddc.entry.js} +2 -2
- package/dist/vega/p-6603081a.entry.js +1 -0
- package/dist/vega/p-6f90d444.js +1 -0
- package/dist/vega/p-7303fff2.entry.js +1 -0
- package/dist/vega/p-7b648a05.entry.js +1 -0
- package/dist/vega/p-7c0b4c36.js +1 -0
- package/dist/vega/p-81b21503.entry.js +1 -0
- package/dist/vega/p-8fae8f9e.js +1 -0
- package/dist/vega/p-924b4e24.js +1 -0
- package/dist/vega/{p-ea78ddfa.entry.js → p-94459733.entry.js} +1 -1
- package/dist/vega/p-a05ca459.entry.js +1 -0
- package/dist/vega/p-a3e80fb2.entry.js +1 -0
- package/dist/vega/p-a7a46358.entry.js +1 -0
- package/dist/vega/p-abd7aeaa.js +1 -0
- package/dist/vega/p-b24da503.entry.js +1 -0
- package/dist/vega/p-b44f3309.js +1 -0
- package/dist/vega/p-b9051ad2.js +1 -0
- package/dist/vega/{p-4ab0d645.js → p-c253d09c.js} +1 -1
- package/dist/vega/p-c56acdd5.entry.js +1 -0
- package/dist/vega/p-cdbbdcc2.js +1 -0
- package/dist/vega/p-d1a06058.entry.js +1 -0
- package/dist/vega/p-d51b04ce.entry.js +1 -0
- package/dist/vega/p-e0446879.js +1 -0
- package/dist/vega/p-e08b6542.entry.js +1 -0
- package/dist/vega/p-f396c69a.js +1 -0
- package/dist/vega/p-fda6c178.entry.js +1 -0
- package/dist/vega/p-ffac4b8c.entry.js +1 -0
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +1 -1
- package/dist/collection/helpers/validator/test/rules/object-array-required-rule.test.js +0 -7
- package/dist/vega/p-0b697841.entry.js +0 -1
- package/dist/vega/p-257b1bc2.entry.js +0 -1
- package/dist/vega/p-3152031c.js +0 -1
- package/dist/vega/p-3c85a11b.entry.js +0 -1
- package/dist/vega/p-49bf2b3a.js +0 -1
- package/dist/vega/p-4a8db510.entry.js +0 -1
- package/dist/vega/p-4e436842.entry.js +0 -1
- package/dist/vega/p-59834ea4.entry.js +0 -1
- package/dist/vega/p-59cfed37.entry.js +0 -1
- package/dist/vega/p-60e1ebe1.entry.js +0 -1
- package/dist/vega/p-629bd266.entry.js +0 -1
- package/dist/vega/p-64e0c944.entry.js +0 -1
- package/dist/vega/p-66b9e86d.entry.js +0 -1
- package/dist/vega/p-74958b1a.js +0 -1
- package/dist/vega/p-74ff73d6.entry.js +0 -1
- package/dist/vega/p-8120e7a1.entry.js +0 -1
- package/dist/vega/p-894c067a.entry.js +0 -1
- package/dist/vega/p-989b36a2.entry.js +0 -1
- package/dist/vega/p-a8a809e1.entry.js +0 -1
- package/dist/vega/p-b6bffdf3.entry.js +0 -1
- package/dist/vega/p-bf6d3c00.entry.js +0 -1
- package/dist/vega/p-c00fde35.entry.js +0 -1
- package/dist/vega/p-c2e96537.entry.js +0 -1
- package/dist/vega/p-ce94a9c5.entry.js +0 -1
- package/dist/vega/p-d03945cb.entry.js +0 -1
- package/dist/vega/p-f41102cd.js +0 -1
- package/dist/vega/p-f5b0ce61.js +0 -1
- package/dist/vega/p-fc49a98e.entry.js +0 -1
- /package/dist/types/helpers/validator/test/rules/{object-array-required-rule.test.d.ts → file-uploader-required-rule.test.d.ts} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { EMAIL_VALIDATION_REGEX } from '../../../constants/validator';
|
|
2
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
2
3
|
/**
|
|
3
4
|
* This class is a rule that checks if the input is a valid email address
|
|
4
5
|
*
|
|
5
|
-
* @
|
|
6
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
6
7
|
*/
|
|
7
|
-
export class EmailFieldRule {
|
|
8
|
+
export class EmailFieldRule extends InternalFormFieldValidationRule {
|
|
8
9
|
/**
|
|
9
10
|
* It checks if the input is a valid email address.
|
|
10
11
|
*
|
|
@@ -2,7 +2,7 @@ import { RequiredFieldRule } from './required-field-rule';
|
|
|
2
2
|
/**
|
|
3
3
|
* A rule that checks the value is empty or not which value type is object array
|
|
4
4
|
*/
|
|
5
|
-
export class
|
|
5
|
+
export class FileUploaderRequiredRule extends RequiredFieldRule {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
8
|
/**
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
1
2
|
/**
|
|
2
3
|
* A rule that checks if input phone number is empty or not
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
5
6
|
*/
|
|
6
|
-
export class InputPhoneNumberRequiredRule {
|
|
7
|
+
export class InputPhoneNumberRequiredRule extends InternalFormFieldValidationRule {
|
|
7
8
|
constructor(phoneNumberValueGetter) {
|
|
9
|
+
super();
|
|
8
10
|
this.phoneNumberValueGetter = phoneNumberValueGetter;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* It checks if the input is a valid value.
|
|
12
14
|
*
|
|
13
15
|
* @param {unknown} input - The value of the input field.
|
|
14
|
-
* @returns {
|
|
16
|
+
* @returns {EvaluateResult} An object with two properties: isValid and message.
|
|
15
17
|
*/
|
|
16
18
|
evaluate(input) {
|
|
17
19
|
if (!this.isAcceptedInputType(input)) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
1
2
|
/**
|
|
2
3
|
* A rule that checks if number is in min and max range
|
|
3
4
|
*/
|
|
4
|
-
export class InputRangeMinAndMaxRule {
|
|
5
|
+
export class InputRangeMinAndMaxRule extends InternalFormFieldValidationRule {
|
|
5
6
|
/**
|
|
6
7
|
* It creates a new instance of the class with the given config.
|
|
7
8
|
*
|
|
@@ -10,6 +11,7 @@ export class InputRangeMinAndMaxRule {
|
|
|
10
11
|
* @param {string} config.maxValue - The max number
|
|
11
12
|
*/
|
|
12
13
|
constructor(config) {
|
|
14
|
+
super();
|
|
13
15
|
/**
|
|
14
16
|
* Generate an invalid result
|
|
15
17
|
*
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
1
2
|
/**
|
|
2
|
-
* A rule that checks if input range is empty or not
|
|
3
|
+
* A rule that checks if the input range is empty or not
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
+
* @augments {InternalFormFieldValidationRule<string[]>}
|
|
5
6
|
*/
|
|
6
|
-
export class InputRangeRequiredRule {
|
|
7
|
+
export class InputRangeRequiredRule extends InternalFormFieldValidationRule {
|
|
7
8
|
/**
|
|
8
9
|
* It checks if the input is a valid value.
|
|
9
10
|
*
|
|
10
11
|
* @param {string[]} input - The value of the input field.
|
|
11
|
-
* @returns {
|
|
12
|
+
* @returns {EvaluateResult} An object with two properties: isValid and message.
|
|
12
13
|
*/
|
|
13
14
|
evaluate(input) {
|
|
14
15
|
if (!this.isAcceptedInputType(input)) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { convertToNumber } from '../../../utils/number';
|
|
2
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
2
3
|
/**
|
|
3
4
|
* A rule that checks if the input is less than or equal to a maximum value
|
|
4
5
|
*
|
|
5
|
-
* @
|
|
6
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
6
7
|
* @property {{ maxValue: number }} config config including the maxValue limit for validation
|
|
7
8
|
*/
|
|
8
|
-
export class MaxNumberRule {
|
|
9
|
+
export class MaxNumberRule extends InternalFormFieldValidationRule {
|
|
9
10
|
/**
|
|
10
11
|
* It creates a new instance of the class with the given config.
|
|
11
12
|
*
|
|
@@ -13,6 +14,7 @@ export class MaxNumberRule {
|
|
|
13
14
|
* @param {number} config.maxValue number of the maxValue
|
|
14
15
|
*/
|
|
15
16
|
constructor(config) {
|
|
17
|
+
super();
|
|
16
18
|
this.config = config;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
1
2
|
/**
|
|
2
3
|
* A rule that checks if the length of input is less than or equal to a maximum value
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
5
6
|
* @property {{ maxStrLength: number }} config config including the maxStrLength limit for validation
|
|
6
7
|
*/
|
|
7
|
-
export class MaxStringLengthRule {
|
|
8
|
+
export class MaxStringLengthRule extends InternalFormFieldValidationRule {
|
|
8
9
|
/**
|
|
9
10
|
* It creates a new instance of the class with the given config.
|
|
10
11
|
*
|
|
@@ -12,6 +13,7 @@ export class MaxStringLengthRule {
|
|
|
12
13
|
* @param {number} config.maxStrLength number of the maxStrLength
|
|
13
14
|
*/
|
|
14
15
|
constructor(config) {
|
|
16
|
+
super();
|
|
15
17
|
this.config = config;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isDateStr, compareIsAfter, compareIsBefore } from '../../../utils/date';
|
|
2
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
2
3
|
/**
|
|
3
4
|
* A rule that checks if date is in minDate and maxDate range
|
|
4
5
|
*/
|
|
5
|
-
export class MinAndMaxDateRule {
|
|
6
|
+
export class MinAndMaxDateRule extends InternalFormFieldValidationRule {
|
|
6
7
|
/**
|
|
7
8
|
* It creates a new instance of the class with the given config.
|
|
8
9
|
*
|
|
@@ -11,6 +12,7 @@ export class MinAndMaxDateRule {
|
|
|
11
12
|
* @param {string} config.maxDate - The maxDate
|
|
12
13
|
*/
|
|
13
14
|
constructor(config) {
|
|
15
|
+
super();
|
|
14
16
|
/**
|
|
15
17
|
* Evaluate if single date is within the min and max date range
|
|
16
18
|
*
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { convertToNumber } from '../../../utils/number';
|
|
2
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
2
3
|
/**
|
|
3
4
|
* A rule that checks if the input is larger than or equal to a minimum value
|
|
4
5
|
*
|
|
5
|
-
* @
|
|
6
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
6
7
|
* @property {{ minValue: number }} config config including the minValue limit for validation
|
|
7
8
|
*/
|
|
8
|
-
export class MinNumberRule {
|
|
9
|
+
export class MinNumberRule extends InternalFormFieldValidationRule {
|
|
9
10
|
/**
|
|
10
11
|
* It creates a new instance of the class with the given config.
|
|
11
12
|
*
|
|
@@ -13,6 +14,7 @@ export class MinNumberRule {
|
|
|
13
14
|
* @param {number} config.minValue number of the minValue
|
|
14
15
|
*/
|
|
15
16
|
constructor(config) {
|
|
17
|
+
super();
|
|
16
18
|
this.config = config;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
1
2
|
/**
|
|
2
3
|
* A rule that checks if the length of input is more than or equal to a minimum value
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
5
6
|
* @property {{ minStrLength: number }} config config including the minStrLength limit for validation
|
|
6
7
|
*/
|
|
7
|
-
export class MinStringLengthRule {
|
|
8
|
+
export class MinStringLengthRule extends InternalFormFieldValidationRule {
|
|
8
9
|
/**
|
|
9
10
|
* It creates a new instance of the class with the given config.
|
|
10
11
|
*
|
|
@@ -12,6 +13,7 @@ export class MinStringLengthRule {
|
|
|
12
13
|
* @param {number} config.minStrLength number of the minStrLength
|
|
13
14
|
*/
|
|
14
15
|
constructor(config) {
|
|
16
|
+
super();
|
|
15
17
|
this.config = config;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
1
2
|
/**
|
|
2
3
|
* A rule that checks if a string is empty or not
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
5
6
|
*/
|
|
6
|
-
export class RequiredFieldRule {
|
|
7
|
+
export class RequiredFieldRule extends InternalFormFieldValidationRule {
|
|
7
8
|
constructor() {
|
|
9
|
+
super(...arguments);
|
|
8
10
|
/**
|
|
9
11
|
* A function that checks if the item is a string, number, or boolean.
|
|
10
12
|
*
|
|
@@ -17,7 +19,7 @@ export class RequiredFieldRule {
|
|
|
17
19
|
* If the input is a number or a boolean, return true. If the input is a string, return true if the string is not empty
|
|
18
20
|
*
|
|
19
21
|
* @param {FormFieldValueType | Array<FormFieldValueType>} input - The input to be evaluated.
|
|
20
|
-
* @returns {
|
|
22
|
+
* @returns {EvaluateResult} An object with two properties: isValid and message.
|
|
21
23
|
*/
|
|
22
24
|
evaluate(input) {
|
|
23
25
|
if (!this.isAcceptedInputType(input)) {
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { VegaRTEContent } from '../../../components/vega-rich-text-editor/dto/content-state';
|
|
2
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
2
3
|
/**
|
|
3
4
|
* A rule that checks if the input range is empty or not
|
|
4
5
|
*
|
|
5
|
-
* @
|
|
6
|
+
* @augments {InternalFormFieldValidationRule<string[]>}
|
|
6
7
|
*/
|
|
7
|
-
export class RichTextEditorRequiredRule {
|
|
8
|
+
export class RichTextEditorRequiredRule extends InternalFormFieldValidationRule {
|
|
8
9
|
/**
|
|
9
10
|
* It checks if the input is a valid value.
|
|
10
11
|
*
|
|
11
12
|
* @param {string[]} input - The value of the input field.
|
|
12
|
-
* @returns {
|
|
13
|
+
* @returns {EvaluateResult} An object with two properties: isValid and message.
|
|
13
14
|
*/
|
|
14
15
|
evaluate(input) {
|
|
15
16
|
var _a, _b;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { isTimeStr } from '../../../utils/date';
|
|
2
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
2
3
|
/**
|
|
3
4
|
* A rule that checks if time is empty or not
|
|
4
5
|
*
|
|
5
|
-
* @
|
|
6
|
+
* @augments {InternalFormFieldValidationRule<string[]>}
|
|
6
7
|
*/
|
|
7
|
-
export class TimeRangeRequiredRule {
|
|
8
|
+
export class TimeRangeRequiredRule extends InternalFormFieldValidationRule {
|
|
8
9
|
/**
|
|
9
10
|
* It creates a new instance of the class with the given config.
|
|
10
11
|
*
|
|
@@ -12,13 +13,14 @@ export class TimeRangeRequiredRule {
|
|
|
12
13
|
* @param {TimeFormat} config.timeFormat - The timeFormat for time value
|
|
13
14
|
*/
|
|
14
15
|
constructor(config) {
|
|
16
|
+
super();
|
|
15
17
|
this.config = config;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* It checks if the input is a valid time string.
|
|
19
21
|
*
|
|
20
22
|
* @param {string} input - The value of the input field.
|
|
21
|
-
* @returns {
|
|
23
|
+
* @returns {EvaluateResult} An object with two properties: isValid and message.
|
|
22
24
|
*/
|
|
23
25
|
evaluate(input) {
|
|
24
26
|
if (!this.isAcceptedInputType(input)) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { convert12HourTo24HourFormat, isTimeStr } from '../../../utils/date';
|
|
2
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
2
3
|
/**
|
|
3
4
|
* A rule that checks if start time is before than end time
|
|
4
5
|
*/
|
|
5
|
-
export class TimeRangeRule {
|
|
6
|
+
export class TimeRangeRule extends InternalFormFieldValidationRule {
|
|
6
7
|
/**
|
|
7
8
|
* It creates a new instance of the class with the given config.
|
|
8
9
|
*
|
|
@@ -10,6 +11,7 @@ export class TimeRangeRule {
|
|
|
10
11
|
* @param {TimeFormat} config.timeFormat - The timeFormat for time value
|
|
11
12
|
*/
|
|
12
13
|
constructor(config) {
|
|
14
|
+
super();
|
|
13
15
|
this.config = config;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { isTimeStr } from '../../../utils/date';
|
|
2
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
2
3
|
/**
|
|
3
4
|
* A rule that checks if time is empty or not
|
|
4
5
|
*
|
|
5
|
-
* @
|
|
6
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
6
7
|
*/
|
|
7
|
-
export class TimeRequiredRule {
|
|
8
|
+
export class TimeRequiredRule extends InternalFormFieldValidationRule {
|
|
8
9
|
/**
|
|
9
10
|
* It creates a new instance of the class with the given config.
|
|
10
11
|
*
|
|
@@ -12,13 +13,14 @@ export class TimeRequiredRule {
|
|
|
12
13
|
* @param {TimeFormat} config.timeFormat - The timeFormat for time value
|
|
13
14
|
*/
|
|
14
15
|
constructor(config) {
|
|
16
|
+
super();
|
|
15
17
|
this.config = config;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* It checks if the input is a valid time string.
|
|
19
21
|
*
|
|
20
22
|
* @param {string} input - The value of the input field.
|
|
21
|
-
* @returns {
|
|
23
|
+
* @returns {EvaluateResult} An object with two properties: isValid and message.
|
|
22
24
|
*/
|
|
23
25
|
evaluate(input) {
|
|
24
26
|
if (!this.isAcceptedInputType(input)) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
1
2
|
/**
|
|
2
|
-
* A rule that checks if toggle switch is required to switch on
|
|
3
|
+
* A rule that checks if the toggle switch is required to switch on
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
+
* @augments {InternalFormFieldValidationRule<boolean>}
|
|
5
6
|
*/
|
|
6
|
-
export class ToggleSwitchRequiredRule {
|
|
7
|
+
export class ToggleSwitchRequiredRule extends InternalFormFieldValidationRule {
|
|
7
8
|
/**
|
|
8
9
|
* If the input is a boolean, return a boolean. If the
|
|
9
10
|
* input is anything else, return false
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AmexRegex, DiscoverRegex, MasterCardRegex, VisaRegex } from '../../../constants/regex';
|
|
2
2
|
import { mapParityDigits, mapStringToNumberArray, sum } from '../../../utils/number';
|
|
3
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
3
4
|
/**
|
|
4
5
|
* A rule that checks if it's a valid credit card number
|
|
5
6
|
*
|
|
6
|
-
* @
|
|
7
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
7
8
|
*/
|
|
8
|
-
export class ValidCreditCardNumberRule {
|
|
9
|
+
export class ValidCreditCardNumberRule extends InternalFormFieldValidationRule {
|
|
9
10
|
/**
|
|
10
11
|
* It takes a string, maps it to an array of numbers, reverses the array, checks the length of the
|
|
11
12
|
* array, maps the even digits to a new array, sums the new array, and returns true if the sum is
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { getCountryCallingCode, parsePhoneNumber } from 'libphonenumber-js';
|
|
2
|
+
import { InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract';
|
|
2
3
|
/**
|
|
3
4
|
* A rule that checks if it's a valid phone number
|
|
4
5
|
*
|
|
5
|
-
* @
|
|
6
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
6
7
|
*/
|
|
7
|
-
export class ValidPhoneNumberRule {
|
|
8
|
+
export class ValidPhoneNumberRule extends InternalFormFieldValidationRule {
|
|
8
9
|
constructor(countryCodeGetter, emptyValueEnabled = false) {
|
|
10
|
+
super();
|
|
9
11
|
this.countryCodeGetter = countryCodeGetter;
|
|
10
12
|
this.emptyValueEnabled = emptyValueEnabled;
|
|
11
13
|
/**
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FileUploaderRequiredRule } from '../../rules/file-uploader-required-rule';
|
|
2
|
+
test('return result as expect when call FileUploaderRequiredRule#checkArrayItemType', () => {
|
|
3
|
+
const rule = new FileUploaderRequiredRule();
|
|
4
|
+
expect(rule.checkArrayItemType({ key: '1', name: 'test.svg', url: '' })).toBeTruthy();
|
|
5
|
+
expect(rule.checkArrayItemType(null)).toBeFalsy();
|
|
6
|
+
expect(rule.checkArrayItemType('Test')).toBeFalsy();
|
|
7
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { RequiredFieldRule, CheckBoxRequiredRule, DateRequiredRule, InputPhoneNumberRequiredRule, InputRangeRequiredRule, RichTextEditorRequiredRule, TimeRangeRequiredRule, ToggleSwitchRequiredRule, FileUploaderRequiredRule, TimeRequiredRule, } from '../../../../index';
|
|
2
|
+
describe('public validation rules', () => {
|
|
3
|
+
test('required field rule should be extendable', () => {
|
|
4
|
+
const mockCanEvaluate = jest.fn();
|
|
5
|
+
const mockShouldShowError = jest.fn();
|
|
6
|
+
const mockEvaluate = jest.fn();
|
|
7
|
+
class CustomRequiredRule extends RequiredFieldRule {
|
|
8
|
+
constructor(fieldName) {
|
|
9
|
+
super();
|
|
10
|
+
this.fieldName = fieldName;
|
|
11
|
+
}
|
|
12
|
+
canEvaluate(input) {
|
|
13
|
+
return mockCanEvaluate(input);
|
|
14
|
+
}
|
|
15
|
+
shouldShowError(status) {
|
|
16
|
+
return mockShouldShowError(status);
|
|
17
|
+
}
|
|
18
|
+
evaluate(input) {
|
|
19
|
+
return mockEvaluate(input);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const customRequiredRule = new CustomRequiredRule('Name');
|
|
23
|
+
expect(customRequiredRule).toBeDefined();
|
|
24
|
+
});
|
|
25
|
+
it('check box required rule should be extendable', () => {
|
|
26
|
+
class CustomRequiredRule extends CheckBoxRequiredRule {
|
|
27
|
+
}
|
|
28
|
+
const customRequiredRule = new CustomRequiredRule();
|
|
29
|
+
expect(customRequiredRule).toBeDefined();
|
|
30
|
+
});
|
|
31
|
+
it('date required rule should be extendable', () => {
|
|
32
|
+
class CustomRequiredRule extends DateRequiredRule {
|
|
33
|
+
}
|
|
34
|
+
const customRequiredRule = new CustomRequiredRule({ mode: 'single' });
|
|
35
|
+
expect(customRequiredRule).toBeDefined();
|
|
36
|
+
});
|
|
37
|
+
it('input phone number required rule should be extendable', () => {
|
|
38
|
+
class CustomRequiredRule extends InputPhoneNumberRequiredRule {
|
|
39
|
+
}
|
|
40
|
+
const mockPhoneNumberInputValueGetter = jest.fn();
|
|
41
|
+
const customRequiredRule = new CustomRequiredRule(mockPhoneNumberInputValueGetter);
|
|
42
|
+
expect(customRequiredRule).toBeDefined();
|
|
43
|
+
});
|
|
44
|
+
it('input range required rule should be extendable', () => {
|
|
45
|
+
class CustomRequiredRule extends InputRangeRequiredRule {
|
|
46
|
+
}
|
|
47
|
+
const customRequiredRule = new CustomRequiredRule();
|
|
48
|
+
expect(customRequiredRule).toBeDefined();
|
|
49
|
+
});
|
|
50
|
+
it('rich text editor required rule should be extendable', () => {
|
|
51
|
+
class CustomRequiredRule extends RichTextEditorRequiredRule {
|
|
52
|
+
}
|
|
53
|
+
const customRequiredRule = new CustomRequiredRule();
|
|
54
|
+
expect(customRequiredRule).toBeDefined();
|
|
55
|
+
});
|
|
56
|
+
it('time range required rule should be extendable', () => {
|
|
57
|
+
class CustomRequiredRule extends TimeRangeRequiredRule {
|
|
58
|
+
}
|
|
59
|
+
const customRequiredRule = new CustomRequiredRule({ timeFormat: '24-hour' });
|
|
60
|
+
expect(customRequiredRule).toBeDefined();
|
|
61
|
+
});
|
|
62
|
+
it('time required rule should be extendable', () => {
|
|
63
|
+
class CustomRequiredRule extends TimeRequiredRule {
|
|
64
|
+
}
|
|
65
|
+
const customRequiredRule = new CustomRequiredRule({ timeFormat: '24-hour' });
|
|
66
|
+
expect(customRequiredRule).toBeDefined();
|
|
67
|
+
});
|
|
68
|
+
it('toggle switch required rule should be extendable', () => {
|
|
69
|
+
class CustomRequiredRule extends ToggleSwitchRequiredRule {
|
|
70
|
+
}
|
|
71
|
+
const customRequiredRule = new CustomRequiredRule();
|
|
72
|
+
expect(customRequiredRule).toBeDefined();
|
|
73
|
+
});
|
|
74
|
+
it('file uploader required rule should be extendable', () => {
|
|
75
|
+
class CustomRequiredRule extends FileUploaderRequiredRule {
|
|
76
|
+
}
|
|
77
|
+
const customRequiredRule = new CustomRequiredRule();
|
|
78
|
+
expect(customRequiredRule).toBeDefined();
|
|
79
|
+
});
|
|
80
|
+
});
|
package/dist/collection/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { w as waitForVega } from './index-d172bafa.js';
|
|
|
9
9
|
import './ui-62e4be97.js';
|
|
10
10
|
import { V as VegaInternalTranslation, a as VegaTranslation, s as staticTranslations } from './translation-c08f2274.js';
|
|
11
11
|
import { T as TypographyUrls } from './typography-396de03f.js';
|
|
12
|
-
import { V as ValidCreditCardNumberRule } from './valid-credit-card-number-rule-
|
|
12
|
+
import { V as ValidCreditCardNumberRule } from './valid-credit-card-number-rule-cc497bec.js';
|
|
13
13
|
import { U as UPDATE_TRANSLATION } from './static-subject-title-8268945e.js';
|
|
14
14
|
import { C as ChangeManager } from './change-manager-6a7eb88c.js';
|
|
15
15
|
import { O as Observer } from './observer-3959f9dd.js';
|
|
@@ -174,6 +174,7 @@ function appGlobalScript () {
|
|
|
174
174
|
injectVegaSkeletonLoaderIntoGlobal();
|
|
175
175
|
injectVegaTranslationIntoGlobal();
|
|
176
176
|
injectVegaRichTextEditorClassIntoGlobal();
|
|
177
|
+
injectVegaPublicValidationRules();
|
|
177
178
|
}
|
|
178
179
|
/**
|
|
179
180
|
* Disable feature flags from the client global defined lists.
|
|
@@ -306,6 +307,16 @@ function injectVegaTranslationIntoGlobal() {
|
|
|
306
307
|
function injectVegaRichTextEditorClassIntoGlobal() {
|
|
307
308
|
globalThis.VegaRTEContent = VegaRTEContent;
|
|
308
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Inject VegaPublicValidationRules to global as a public api
|
|
312
|
+
*/
|
|
313
|
+
function injectVegaPublicValidationRules() {
|
|
314
|
+
void import('./public-rules-413f6a17.js').then((module) => {
|
|
315
|
+
Object.entries(module).forEach(([name, value]) => {
|
|
316
|
+
globalThis[name] = value;
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
}
|
|
309
320
|
|
|
310
321
|
const globalScripts = appGlobalScript;
|
|
311
322
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { I as InternalFormFieldValidationRule } from './internal-form-field-validation-rule.abstract-f5b6bdbf.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A rule that checks if a string is empty or not
|
|
5
|
+
*
|
|
6
|
+
* @augments {InternalFormFieldValidationRule<string>}
|
|
7
|
+
*/
|
|
8
|
+
class CheckBoxRequiredRule extends InternalFormFieldValidationRule {
|
|
9
|
+
/**
|
|
10
|
+
* If the input is a boolean, return a boolean. If the input is a string, return a boolean. If the
|
|
11
|
+
* input is anything else, return false
|
|
12
|
+
*
|
|
13
|
+
* @param {string | boolean} input - The input to be evaluated.
|
|
14
|
+
* @returns {EvaluateResult} - An object with two properties: isValid and message.
|
|
15
|
+
*/
|
|
16
|
+
evaluate(input) {
|
|
17
|
+
if (typeof input === 'boolean') {
|
|
18
|
+
return {
|
|
19
|
+
isValid: input,
|
|
20
|
+
message: input ? '' : 'This field is required',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else if (typeof input === 'string') {
|
|
24
|
+
return {
|
|
25
|
+
isValid: input !== '',
|
|
26
|
+
message: input !== '' ? '' : 'This field is required',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return {
|
|
31
|
+
isValid: false,
|
|
32
|
+
message: 'This field is required',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* If the input is accepted and the status is not disabled and visible, then return true
|
|
38
|
+
*
|
|
39
|
+
* @param {unknown} input - The input to be evaluated.
|
|
40
|
+
* @param {FormFieldStatusMeta} [status] - FormFieldStatusMeta
|
|
41
|
+
* @returns {boolean} The return value is a boolean that indicates whether the input can be evaluated.
|
|
42
|
+
*/
|
|
43
|
+
canEvaluate(input, status) {
|
|
44
|
+
return status
|
|
45
|
+
? this.isAcceptedInputType(input) && !status.disabled && status.visible
|
|
46
|
+
: this.isAcceptedInputType(input);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* If the field is not disabled, visible, and has been touched or modified, then show the error
|
|
50
|
+
*
|
|
51
|
+
* @param {FormFieldStatusMeta} status - FormFieldStatusMeta
|
|
52
|
+
* @returns {boolean} A boolean value.
|
|
53
|
+
*/
|
|
54
|
+
shouldShowError(status) {
|
|
55
|
+
return !status.disabled && status.visible && (status.touched || status.modified);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* If the input is a string, number, boolean, or null, return true, otherwise return false.
|
|
59
|
+
*
|
|
60
|
+
* @param {unknown} input - The input value to be validated.
|
|
61
|
+
* @returns {boolean} a boolean value.
|
|
62
|
+
*/
|
|
63
|
+
isAcceptedInputType(input) {
|
|
64
|
+
return typeof input === 'string' || typeof input === 'boolean' || input === null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { CheckBoxRequiredRule as C };
|
|
@@ -84,4 +84,4 @@ const convert12HourTo24HourFormat = (time) => {
|
|
|
84
84
|
return time;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
export {
|
|
87
|
+
export { isTimeStr as a, compareIsBefore as b, compareIsSameOrBefore as c, compareIsAfter as d, convert12HourTo24HourFormat as e, isDateStr as i, pad as p };
|