@acorex/core 16.0.2 → 17.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/common/README.md +3 -0
- package/common/countries/countries.data.d.ts +2 -0
- package/common/countries/country.d.ts +13 -0
- package/common/index.d.ts +2 -0
- package/config/README.md +3 -0
- package/config/index.d.ts +2 -0
- package/config/lib/configs.d.ts +6 -0
- package/config/lib/configs.service.d.ts +12 -0
- package/date-time/README.md +3 -0
- package/date-time/index.d.ts +10 -0
- package/date-time/lib/calendar.service.d.ts +27 -0
- package/date-time/lib/dateTime.config.d.ts +12 -0
- package/date-time/lib/datetime.class.d.ts +138 -0
- package/date-time/lib/datetime.module.d.ts +8 -0
- package/date-time/lib/datetime.pipe.d.ts +12 -0
- package/date-time/lib/formatters/datetime-formatter.d.ts +19 -0
- package/date-time/lib/formatters/timeleft-formatter.d.ts +16 -0
- package/date-time/lib/georgian.calendar.d.ts +21 -0
- package/date-time/lib/holidays.loader.d.ts +21 -0
- package/date-time/lib/jalali.calendar.d.ts +40 -0
- package/esm2022/common/acorex-core-common.mjs +5 -0
- package/esm2022/common/countries/countries.data.mjs +2625 -0
- package/esm2022/common/countries/country.mjs +2 -0
- package/esm2022/common/index.mjs +3 -0
- package/esm2022/config/acorex-core-config.mjs +5 -0
- package/esm2022/config/index.mjs +3 -0
- package/esm2022/config/lib/configs.mjs +7 -0
- package/esm2022/config/lib/configs.service.mjs +27 -0
- package/esm2022/date-time/acorex-core-date-time.mjs +5 -0
- package/esm2022/date-time/index.mjs +11 -0
- package/esm2022/date-time/lib/calendar.service.mjs +100 -0
- package/esm2022/date-time/lib/dateTime.config.mjs +50 -0
- package/esm2022/date-time/lib/datetime.class.mjs +337 -0
- package/esm2022/date-time/lib/datetime.module.mjs +27 -0
- package/esm2022/date-time/lib/datetime.pipe.mjs +29 -0
- package/esm2022/date-time/lib/formatters/datetime-formatter.mjs +32 -0
- package/esm2022/date-time/lib/formatters/timeleft-formatter.mjs +91 -0
- package/esm2022/date-time/lib/georgian.calendar.mjs +203 -0
- package/esm2022/date-time/lib/holidays.loader.mjs +13 -0
- package/esm2022/date-time/lib/jalali.calendar.mjs +440 -0
- package/esm2022/events/acorex-core-events.mjs +5 -0
- package/esm2022/events/index.mjs +3 -0
- package/esm2022/events/lib/event.service.mjs +43 -0
- package/esm2022/events/lib/event.type.mjs +6 -0
- package/esm2022/file/acorex-core-file.mjs +5 -0
- package/esm2022/file/index.mjs +7 -0
- package/esm2022/file/lib/file-download-ref.class.mjs +12 -0
- package/esm2022/file/lib/file-download-result.class.mjs +45 -0
- package/esm2022/file/lib/file-size-formatter.mjs +24 -0
- package/esm2022/file/lib/file-upload-ref.class.mjs +12 -0
- package/esm2022/file/lib/file.module.mjs +20 -0
- package/esm2022/file/lib/file.service.mjs +103 -0
- package/esm2022/format/acorex-core-format.mjs +5 -0
- package/esm2022/format/index.mjs +8 -0
- package/esm2022/format/lib/format.config.mjs +3 -0
- package/esm2022/format/lib/format.module.mjs +64 -0
- package/esm2022/format/lib/format.pipe.mjs +37 -0
- package/esm2022/format/lib/format.service.mjs +95 -0
- package/esm2022/format/lib/format.types.mjs +2 -0
- package/esm2022/format/lib/formatters/number-formatter.mjs +74 -0
- package/esm2022/format/lib/formatters/string-formatter.mjs +15 -0
- package/esm2022/image/acorex-core-image.mjs +5 -0
- package/esm2022/image/index.mjs +2 -0
- package/esm2022/image/lib/image.service.mjs +43 -0
- package/esm2022/index.mjs +2 -44
- package/esm2022/memorize/acorex-core-memorize.mjs +5 -0
- package/esm2022/memorize/index.mjs +2 -0
- package/esm2022/memorize/lib/memorize.decorator.mjs +19 -0
- package/esm2022/pipes/acorex-core-pipes.mjs +5 -0
- package/esm2022/pipes/index.mjs +2 -0
- package/esm2022/pipes/lib/safe/safe.pipe.mjs +38 -0
- package/esm2022/platform/acorex-core-platform.mjs +5 -0
- package/esm2022/platform/index.mjs +2 -0
- package/esm2022/platform/lib/platform.service.mjs +225 -0
- package/esm2022/storage/acorex-core-storage.mjs +5 -0
- package/esm2022/storage/cookie-storage.service.mjs +202 -0
- package/esm2022/storage/index.mjs +5 -0
- package/esm2022/storage/local-storage.service.mjs +58 -0
- package/esm2022/storage/session-storage.service.mjs +22 -0
- package/esm2022/storage/storage.interface.mjs +2 -0
- package/esm2022/translation/acorex-core-translation.mjs +5 -0
- package/esm2022/translation/index.mjs +9 -0
- package/esm2022/translation/lib/translation-scope.resolver.mjs +11 -0
- package/esm2022/translation/lib/translation.config.mjs +20 -0
- package/esm2022/translation/lib/translation.loader.mjs +14 -0
- package/esm2022/translation/lib/translation.module.mjs +40 -0
- package/esm2022/translation/lib/translation.service.mjs +173 -0
- package/esm2022/translation/lib/translation.types.mjs +2 -0
- package/esm2022/translation/lib/translator.directive.mjs +28 -0
- package/esm2022/translation/lib/translator.pipe.mjs +23 -0
- package/esm2022/types/acorex-core-types.mjs +5 -0
- package/esm2022/types/index.mjs +2 -0
- package/esm2022/utils/acorex-core-utils.mjs +5 -0
- package/esm2022/utils/index.mjs +6 -0
- package/esm2022/utils/lib/auto-unsubscribe.mjs +36 -0
- package/esm2022/utils/lib/color-util.mjs +111 -0
- package/esm2022/utils/lib/drawing-util.mjs +35 -0
- package/esm2022/utils/lib/html-util.mjs +39 -0
- package/esm2022/utils/lib/string-util.mjs +19 -0
- package/esm2022/validation/acorex-core-validation.mjs +5 -0
- package/esm2022/validation/index.mjs +18 -0
- package/esm2022/validation/lib/rules/between-rule.mjs +31 -0
- package/esm2022/validation/lib/rules/callback-rule.mjs +29 -0
- package/esm2022/validation/lib/rules/equal-rule.mjs +26 -0
- package/esm2022/validation/lib/rules/greater-than.mjs +29 -0
- package/esm2022/validation/lib/rules/length-rule.mjs +26 -0
- package/esm2022/validation/lib/rules/less-than-rule.mjs +29 -0
- package/esm2022/validation/lib/rules/maxlength-rule.mjs +27 -0
- package/esm2022/validation/lib/rules/minlength-rule.mjs +26 -0
- package/esm2022/validation/lib/rules/regex-rule.mjs +49 -0
- package/esm2022/validation/lib/rules/required-rule.mjs +36 -0
- package/esm2022/validation/lib/validation.config.mjs +33 -0
- package/esm2022/validation/lib/validation.module.mjs +84 -0
- package/esm2022/validation/lib/validation.service.mjs +98 -0
- package/esm2022/validation/lib/validation.types.mjs +3 -0
- package/events/README.md +3 -0
- package/events/index.d.ts +2 -0
- package/{lib/services → events/lib}/event.service.d.ts +8 -0
- package/events/lib/event.type.d.ts +5 -0
- package/fesm2022/acorex-core-common.mjs +2631 -0
- package/fesm2022/acorex-core-common.mjs.map +1 -0
- package/fesm2022/acorex-core-config.mjs +39 -0
- package/fesm2022/acorex-core-config.mjs.map +1 -0
- package/fesm2022/acorex-core-date-time.mjs +1305 -0
- package/fesm2022/acorex-core-date-time.mjs.map +1 -0
- package/fesm2022/acorex-core-events.mjs +56 -0
- package/fesm2022/acorex-core-events.mjs.map +1 -0
- package/fesm2022/acorex-core-file.mjs +214 -0
- package/fesm2022/acorex-core-file.mjs.map +1 -0
- package/fesm2022/acorex-core-format.mjs +282 -0
- package/fesm2022/acorex-core-format.mjs.map +1 -0
- package/fesm2022/acorex-core-image.mjs +50 -0
- package/fesm2022/acorex-core-image.mjs.map +1 -0
- package/fesm2022/acorex-core-memorize.mjs +26 -0
- package/fesm2022/acorex-core-memorize.mjs.map +1 -0
- package/fesm2022/acorex-core-pipes.mjs +44 -0
- package/fesm2022/acorex-core-pipes.mjs.map +1 -0
- package/fesm2022/acorex-core-platform.mjs +232 -0
- package/fesm2022/acorex-core-platform.mjs.map +1 -0
- package/fesm2022/acorex-core-storage.mjs +285 -0
- package/fesm2022/acorex-core-storage.mjs.map +1 -0
- package/fesm2022/acorex-core-translation.mjs +293 -0
- package/fesm2022/acorex-core-translation.mjs.map +1 -0
- package/fesm2022/acorex-core-types.mjs +6 -0
- package/fesm2022/acorex-core-types.mjs.map +1 -0
- package/fesm2022/acorex-core-utils.mjs +247 -0
- package/fesm2022/acorex-core-utils.mjs.map +1 -0
- package/fesm2022/acorex-core-validation.mjs +488 -0
- package/fesm2022/acorex-core-validation.mjs.map +1 -0
- package/fesm2022/acorex-core.mjs +2 -2309
- package/fesm2022/acorex-core.mjs.map +1 -1
- package/file/README.md +3 -0
- package/file/index.d.ts +6 -0
- package/file/lib/file-download-ref.class.d.ts +6 -0
- package/file/lib/file-download-result.class.d.ts +8 -0
- package/file/lib/file-size-formatter.d.ts +16 -0
- package/file/lib/file-upload-ref.class.d.ts +5 -0
- package/file/lib/file.module.d.ts +7 -0
- package/file/lib/file.service.d.ts +18 -0
- package/format/README.md +3 -0
- package/format/index.d.ts +7 -0
- package/format/lib/format.config.d.ts +5 -0
- package/format/lib/format.module.d.ts +18 -0
- package/format/lib/format.pipe.d.ts +12 -0
- package/format/lib/format.service.d.ts +43 -0
- package/format/lib/format.types.d.ts +4 -0
- package/format/lib/formatters/number-formatter.d.ts +23 -0
- package/format/lib/formatters/string-formatter.d.ts +14 -0
- package/image/README.md +3 -0
- package/image/index.d.ts +1 -0
- package/image/lib/image.service.d.ts +11 -0
- package/index.d.ts +1 -43
- package/memorize/README.md +3 -0
- package/memorize/index.d.ts +1 -0
- package/memorize/lib/memorize.decorator.d.ts +1 -0
- package/package.json +98 -5
- package/pipes/README.md +3 -0
- package/pipes/index.d.ts +1 -0
- package/pipes/lib/safe/safe.pipe.d.ts +10 -0
- package/platform/README.md +3 -0
- package/platform/index.d.ts +1 -0
- package/{lib/platform → platform/lib}/platform.service.d.ts +14 -6
- package/storage/README.md +3 -0
- package/storage/cookie-storage.service.d.ts +104 -0
- package/storage/index.d.ts +4 -0
- package/storage/local-storage.service.d.ts +16 -0
- package/storage/session-storage.service.d.ts +10 -0
- package/storage/storage.interface.d.ts +14 -0
- package/translation/README.md +3 -0
- package/translation/index.d.ts +8 -0
- package/translation/lib/translation-scope.resolver.d.ts +2 -0
- package/translation/lib/translation.config.d.ts +14 -0
- package/translation/lib/translation.loader.d.ts +14 -0
- package/translation/lib/translation.module.d.ts +8 -0
- package/translation/lib/translation.service.d.ts +31 -0
- package/translation/lib/translation.types.d.ts +10 -0
- package/translation/lib/translator.directive.d.ts +12 -0
- package/translation/lib/translator.pipe.d.ts +12 -0
- package/types/README.md +3 -0
- package/types/index.d.ts +2 -0
- package/utils/README.md +3 -0
- package/utils/index.d.ts +5 -0
- package/utils/lib/auto-unsubscribe.d.ts +12 -0
- package/utils/lib/color-util.d.ts +24 -0
- package/utils/lib/drawing-util.d.ts +18 -0
- package/utils/lib/html-util.d.ts +5 -0
- package/utils/lib/string-util.d.ts +6 -0
- package/validation/README.md +3 -0
- package/validation/index.d.ts +14 -0
- package/validation/lib/rules/between-rule.d.ts +18 -0
- package/validation/lib/rules/callback-rule.d.ts +23 -0
- package/validation/lib/rules/equal-rule.d.ts +17 -0
- package/validation/lib/rules/greater-than.d.ts +17 -0
- package/validation/lib/rules/length-rule.d.ts +17 -0
- package/validation/lib/rules/less-than-rule.d.ts +17 -0
- package/validation/lib/rules/maxlength-rule.d.ts +16 -0
- package/validation/lib/rules/minlength-rule.d.ts +16 -0
- package/validation/lib/rules/regex-rule.d.ts +17 -0
- package/validation/lib/rules/required-rule.d.ts +16 -0
- package/validation/lib/validation.config.d.ts +15 -0
- package/validation/lib/validation.module.d.ts +17 -0
- package/validation/lib/validation.service.d.ts +35 -0
- package/validation/lib/validation.types.d.ts +21 -0
- package/esm2022/lib/classes/base-page.class.mjs +0 -26
- package/esm2022/lib/classes/color.class.mjs +0 -49
- package/esm2022/lib/classes/datetime.class.mjs +0 -323
- package/esm2022/lib/classes/menu.class.mjs +0 -35
- package/esm2022/lib/classes/navigator.class.mjs +0 -2
- package/esm2022/lib/classes/popup.class.mjs +0 -2
- package/esm2022/lib/classes/promise.class.mjs +0 -21
- package/esm2022/lib/classes/sectionlist.class.mjs +0 -2
- package/esm2022/lib/classes/select.class.mjs +0 -8
- package/esm2022/lib/core.module.mjs +0 -27
- package/esm2022/lib/error/error.class.mjs +0 -2
- package/esm2022/lib/error/error.module.mjs +0 -19
- package/esm2022/lib/error/error.service.mjs +0 -22
- package/esm2022/lib/events/keyboard.mjs +0 -2
- package/esm2022/lib/http/http-error.class.mjs +0 -2
- package/esm2022/lib/http/http-events.interceptor.mjs +0 -3
- package/esm2022/lib/http/http-request.class.mjs +0 -2
- package/esm2022/lib/http/http-result.class.mjs +0 -25
- package/esm2022/lib/http/http.module.mjs +0 -35
- package/esm2022/lib/http/http.service.mjs +0 -148
- package/esm2022/lib/locale/en.json +0 -255
- package/esm2022/lib/locale/fa.json +0 -245
- package/esm2022/lib/pipe/datetime.pipe.mjs +0 -25
- package/esm2022/lib/pipe/htmlToText.pipe.mjs +0 -25
- package/esm2022/lib/platform/index.mjs +0 -2
- package/esm2022/lib/platform/platform.service.mjs +0 -152
- package/esm2022/lib/services/config.mjs +0 -29
- package/esm2022/lib/services/event.service.mjs +0 -34
- package/esm2022/lib/services/navigator.service.mjs +0 -10
- package/esm2022/lib/services/storage.service.mjs +0 -16
- package/esm2022/lib/translator/translator.mjs +0 -26
- package/esm2022/lib/translator/translator.module.mjs +0 -25
- package/esm2022/lib/translator/translator.pipe.mjs +0 -24
- package/esm2022/lib/translator/translator.service.mjs +0 -21
- package/esm2022/lib/utils/array/array-util.mjs +0 -133
- package/esm2022/lib/utils/html/html-util.mjs +0 -200
- package/esm2022/lib/utils/html/html.module.mjs +0 -19
- package/esm2022/lib/utils/math/math-util.mjs +0 -6
- package/esm2022/lib/utils/object/object-util.mjs +0 -83
- package/esm2022/lib/utils/render/on-demand-preload-strategy.service.mjs +0 -21
- package/esm2022/lib/utils/render/render.service.mjs +0 -109
- package/esm2022/lib/utils/render/rendering.module.mjs +0 -35
- package/esm2022/lib/utils/scroll/scroll.directive.mjs +0 -56
- package/esm2022/lib/utils/scroll/scroll.module.mjs +0 -19
- package/esm2022/lib/utils/separator/separator.module.mjs +0 -19
- package/esm2022/lib/utils/separator/separator.pipe.mjs +0 -33
- package/lib/classes/base-page.class.d.ts +0 -13
- package/lib/classes/color.class.d.ts +0 -17
- package/lib/classes/datetime.class.d.ts +0 -63
- package/lib/classes/menu.class.d.ts +0 -34
- package/lib/classes/navigator.class.d.ts +0 -5
- package/lib/classes/popup.class.d.ts +0 -12
- package/lib/classes/promise.class.d.ts +0 -7
- package/lib/classes/sectionlist.class.d.ts +0 -8
- package/lib/classes/select.class.d.ts +0 -7
- package/lib/core.module.d.ts +0 -9
- package/lib/error/error.class.d.ts +0 -4
- package/lib/error/error.module.d.ts +0 -7
- package/lib/error/error.service.d.ts +0 -13
- package/lib/events/keyboard.d.ts +0 -2
- package/lib/http/http-error.class.d.ts +0 -7
- package/lib/http/http-events.interceptor.d.ts +0 -10
- package/lib/http/http-request.class.d.ts +0 -14
- package/lib/http/http-result.class.d.ts +0 -11
- package/lib/http/http.module.d.ts +0 -10
- package/lib/http/http.service.d.ts +0 -23
- package/lib/pipe/datetime.pipe.d.ts +0 -8
- package/lib/pipe/htmlToText.pipe.d.ts +0 -7
- package/lib/platform/index.d.ts +0 -1
- package/lib/services/config.d.ts +0 -9
- package/lib/services/navigator.service.d.ts +0 -8
- package/lib/services/storage.service.d.ts +0 -7
- package/lib/translator/translator.d.ts +0 -9
- package/lib/translator/translator.module.d.ts +0 -8
- package/lib/translator/translator.pipe.d.ts +0 -8
- package/lib/translator/translator.service.d.ts +0 -8
- package/lib/utils/array/array-util.d.ts +0 -6
- package/lib/utils/html/html-util.d.ts +0 -62
- package/lib/utils/html/html.module.d.ts +0 -8
- package/lib/utils/math/math-util.d.ts +0 -3
- package/lib/utils/object/object-util.d.ts +0 -7
- package/lib/utils/render/on-demand-preload-strategy.service.d.ts +0 -10
- package/lib/utils/render/render.service.d.ts +0 -18
- package/lib/utils/render/rendering.module.d.ts +0 -8
- package/lib/utils/scroll/scroll.directive.d.ts +0 -18
- package/lib/utils/scroll/scroll.module.d.ts +0 -8
- package/lib/utils/separator/separator.module.d.ts +0 -8
- package/lib/utils/separator/separator.pipe.d.ts +0 -8
@@ -0,0 +1,31 @@
|
|
1
|
+
import { isEmpty } from 'lodash-es';
|
2
|
+
import { Injectable } from '@angular/core';
|
3
|
+
import * as i0 from "@angular/core";
|
4
|
+
export class AXBetweenValidationRule {
|
5
|
+
get name() {
|
6
|
+
return 'between';
|
7
|
+
}
|
8
|
+
async validate(value, options) {
|
9
|
+
let isValid;
|
10
|
+
if (options.inclusive) {
|
11
|
+
isValid = value >= options.lowerValue && value <= options.upperValue;
|
12
|
+
}
|
13
|
+
else {
|
14
|
+
isValid = value > options.lowerValue && value < options.upperValue;
|
15
|
+
}
|
16
|
+
const rangeType = options.inclusive ? 'inclusive' : 'exclusive';
|
17
|
+
const baseMessage = `The value must be within the ${rangeType} range of ${options.lowerValue} to ${options.upperValue}.`;
|
18
|
+
return {
|
19
|
+
rule: this.name,
|
20
|
+
result: isValid || isEmpty(value),
|
21
|
+
message: isValid ? '' : options?.message ?? baseMessage,
|
22
|
+
value: value,
|
23
|
+
};
|
24
|
+
}
|
25
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXBetweenValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
26
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXBetweenValidationRule }); }
|
27
|
+
}
|
28
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXBetweenValidationRule, decorators: [{
|
29
|
+
type: Injectable
|
30
|
+
}] });
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmV0d2Vlbi1ydWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9jb3JlL3ZhbGlkYXRpb24vc3JjL2xpYi9ydWxlcy9iZXR3ZWVuLXJ1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLFdBQVcsQ0FBQztBQU1wQyxPQU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B0aW9uczogQVhCZXR3ZWVuVmFsaWRhdGlvblJ1bGVPcHRpb25zPFQ+XG4gICk6IFByb21pc2U8QVhWYWxpZGF0aW9uUnVsZVJlc3VsdD4ge1xuICAgIGxldCBpc1ZhbGlkO1xuICAgIGlmIChvcHRpb25zLmluY2x1c2l2ZSkge1xuICAgICAgaXNWYWxpZCA9IHZhbHVlID49IG9wdGlvbnMubG93ZXJWYWx1ZSAmJiB2YWx1ZSA8PSBvcHRpb25zLnVwcGVyVmFsdWU7XG4gICAgfSBlbHNlIHtcbiAgICAgIGlzVmFsaWQgPSB2YWx1ZSA+IG9wdGlvbnMubG93ZXJWYWx1ZSAmJiB2YWx1ZSA8IG9wdGlvbnMudXBwZXJWYWx1ZTtcbiAgICB9XG5cbiAgICBjb25zdCByYW5nZVR5cGUgPSBvcHRpb25zLmluY2x1c2l2ZSA/ICdpbmNsdXNpdmUnIDogJ2V4Y2x1c2l2ZSc7XG4gICAgY29uc3QgYmFzZU1lc3NhZ2UgPSBgVGhlIHZhbHVlIG11c3QgYmUgd2l0aGluIHRoZSAke3JhbmdlVHlwZX0gcmFuZ2Ugb2YgJHtvcHRpb25zLmxvd2VyVmFsdWV9IHRvICR7b3B0aW9ucy51cHBlclZhbHVlfS5gO1xuXG4gICAgcmV0dXJuIHtcbiAgICAgIHJ1bGU6IHRoaXMubmFtZSxcbiAgICAgIHJlc3VsdDogaXNWYWxpZCB8fCBpc0VtcHR5KHZhbHVlKSxcbiAgICAgIG1lc3NhZ2U6IGlzVmFsaWQgPyAnJyA6IG9wdGlvbnM/Lm1lc3NhZ2UgPz8gYmFzZU1lc3NhZ2UsXG4gICAgICB2YWx1ZTogdmFsdWUsXG4gICAgfTtcbiAgfVxufVxuIl19
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { Injectable } from '@angular/core';
|
2
|
+
import * as i0 from "@angular/core";
|
3
|
+
export class AXCallbackValidationRule {
|
4
|
+
get name() {
|
5
|
+
return 'callback';
|
6
|
+
}
|
7
|
+
async validate(value, options) {
|
8
|
+
const validationResult = options?.validate(value, options) || {
|
9
|
+
result: false,
|
10
|
+
message: 'Invalid callback function',
|
11
|
+
};
|
12
|
+
const createResult = (result) => ({
|
13
|
+
rule: this.name,
|
14
|
+
result: result.result,
|
15
|
+
message: result.message ?? options?.message ?? '',
|
16
|
+
value: value,
|
17
|
+
});
|
18
|
+
if (validationResult instanceof Promise) {
|
19
|
+
return validationResult.then(createResult);
|
20
|
+
}
|
21
|
+
return createResult(validationResult);
|
22
|
+
}
|
23
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXCallbackValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
24
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXCallbackValidationRule }); }
|
25
|
+
}
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXCallbackValidationRule, decorators: [{
|
27
|
+
type: Injectable
|
28
|
+
}] });
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FsbGJhY2stcnVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS92YWxpZGF0aW9uL3NyYy9saWIvcnVsZXMvY2FsbGJhY2stcnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOztBQTJCM0MsTUFBTSxPQUFPLHdCQUF3QjtJQUNuQyxJQUFJLElBQUk7UUFDTixPQUFPLFVBQVUsQ0FBQztJQUNwQixDQUFDO0lBRUQsS0FBSyxDQUFDLFFBQVEsQ0FDWixLQUFRLEVBQ1IsT0FBMkM7UUFFM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4gICAgICBtZXNzYWdlOiAnSW52YWxpZCBjYWxsYmFjayBmdW5jdGlvbicsXG4gICAgfTtcbiAgICBjb25zdCBjcmVhdGVSZXN1bHQgPSAocmVzdWx0OiB7IHJlc3VsdDogYm9vbGVhbjsgbWVzc2FnZT86IHN0cmluZyB9KSA9PiAoe1xuICAgICAgcnVsZTogdGhpcy5uYW1lLFxuICAgICAgcmVzdWx0OiByZXN1bHQucmVzdWx0LFxuICAgICAgbWVzc2FnZTogcmVzdWx0Lm1lc3NhZ2UgPz8gb3B0aW9ucz8ubWVzc2FnZSA/PyAnJyxcbiAgICAgIHZhbHVlOiB2YWx1ZSxcbiAgICB9KTtcblxuICAgIGlmICh2YWxpZGF0aW9uUmVzdWx0IGluc3RhbmNlb2YgUHJvbWlzZSkge1xuICAgICAgcmV0dXJuIHZhbGlkYXRpb25SZXN1bHQudGhlbihjcmVhdGVSZXN1bHQpO1xuICAgIH1cblxuICAgIHJldHVybiBjcmVhdGVSZXN1bHQodmFsaWRhdGlvblJlc3VsdCk7XG4gIH1cbn1cbiJdfQ==
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// ax-equal-validation-rule.ts
|
2
|
+
import { isEqual } from 'lodash-es';
|
3
|
+
import { Injectable } from '@angular/core';
|
4
|
+
import * as i0 from "@angular/core";
|
5
|
+
export class AXEqualValidationRule {
|
6
|
+
get name() {
|
7
|
+
return 'equal';
|
8
|
+
}
|
9
|
+
async validate(value, options) {
|
10
|
+
const isValueEqual = isEqual(value, options.value);
|
11
|
+
const isValid = options.not ? !isValueEqual : isValueEqual;
|
12
|
+
const defaultMessage = `The value must ${options.not ? 'not ' : ''}be equal to ${options.value}.`;
|
13
|
+
return {
|
14
|
+
rule: this.name,
|
15
|
+
result: isValid,
|
16
|
+
message: isValid ? '' : options?.message ?? defaultMessage,
|
17
|
+
value: value,
|
18
|
+
};
|
19
|
+
}
|
20
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXEqualValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
21
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXEqualValidationRule }); }
|
22
|
+
}
|
23
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXEqualValidationRule, decorators: [{
|
24
|
+
type: Injectable
|
25
|
+
}] });
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXF1YWwtcnVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS92YWxpZGF0aW9uL3NyYy9saWIvcnVsZXMvZXF1YWwtcnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSw4QkFBOEI7QUFDOUIsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLFdBQVcsQ0FBQztBQU1wQyxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOztBQWEzQyxNQUFNLE9BQU8scUJBQXFCO0lBQ2hDLElBQUksSUFBSTtRQUNOLE9BQU8sT0FBTyxDQUFDO0lBQ2pCLENBQUM7SUFFRCxLQUFLLENBQUMsUUFBUSxDQUNaLEtBQVUsRUFDVixPQUFxQztRQUVyQyxNQUFNLFlBQVksR0FBRyxPQUFPLENBQUMsS0FBSyxFQUFFLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQztRQUNuRCxNQUFNLE9BQU8sR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUMsWUFBWSxDQUFDO1FBRTNELE1BQU0sY0FBYyxHQUFHLGtCQUNyQixPQUFPLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQ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OiBBWEVxdWFsVmFsaWRhdGlvblJ1bGVPcHRpb25zO1xuICB9XG59XG5ASW5qZWN0YWJsZSgpXG5leHBvcnQgY2xhc3MgQVhFcXVhbFZhbGlkYXRpb25SdWxlIGltcGxlbWVudHMgQVhWYWxpZGF0aW9uUnVsZSB7XG4gIGdldCBuYW1lKCk6IHN0cmluZyB7XG4gICAgcmV0dXJuICdlcXVhbCc7XG4gIH1cblxuICBhc3luYyB2YWxpZGF0ZShcbiAgICB2YWx1ZTogYW55LFxuICAgIG9wdGlvbnM6IEFYRXF1YWxWYWxpZGF0aW9uUnVsZU9wdGlvbnNcbiAgKTogUHJvbWlzZTxBWFZhbGlkYXRpb25SdWxlUmVzdWx0PiB7XG4gICAgY29uc3QgaXNWYWx1ZUVxdWFsID0gaXNFcXVhbCh2YWx1ZSwgb3B0aW9ucy52YWx1ZSk7XG4gICAgY29uc3QgaXNWYWxpZCA9IG9wdGlvbnMubm90ID8gIWlzVmFsdWVFcXVhbCA6IGlzVmFsdWVFcXVhbDtcblxuICAgIGNvbnN0IGRlZmF1bHRNZXNzYWdlID0gYFRoZSB2YWx1ZSBtdXN0ICR7XG4gICAgICBvcHRpb25zLm5vdCA/ICdub3QgJyA6ICcnXG4gICAgfWJlIGVxdWFsIHRvICR7b3B0aW9ucy52YWx1ZX0uYDtcbiAgICByZXR1cm4ge1xuICAgICAgcnVsZTogdGhpcy5uYW1lLFxuICAgICAgcmVzdWx0OiBpc1ZhbGlkLFxuICAgICAgbWVzc2FnZTogaXNWYWxpZCA/ICcnIDogb3B0aW9ucz8ubWVzc2FnZSA/PyBkZWZhdWx0TWVzc2FnZSxcbiAgICAgIHZhbHVlOiB2YWx1ZSxcbiAgICB9O1xuICB9XG59XG4iXX0=
|
@@ -0,0 +1,29 @@
|
|
1
|
+
// ax-greater-than-validation-rule.ts
|
2
|
+
import { isNull, isUndefined } from 'lodash-es';
|
3
|
+
import { Injectable } from '@angular/core';
|
4
|
+
import * as i0 from "@angular/core";
|
5
|
+
export class AXGreaterThanValidationRule {
|
6
|
+
get name() {
|
7
|
+
return 'greaterThan';
|
8
|
+
}
|
9
|
+
async validate(value, options) {
|
10
|
+
const isValid = isNull(value) || isUndefined(value)
|
11
|
+
? true
|
12
|
+
: options.inclusive
|
13
|
+
? value >= options.value
|
14
|
+
: value > options.value;
|
15
|
+
const baseMessage = `The value must be ${options.inclusive ? 'greater than or equal to' : 'greater than'} ${options.value}.`;
|
16
|
+
return {
|
17
|
+
rule: this.name,
|
18
|
+
result: isValid,
|
19
|
+
message: isValid ? '' : options?.message ?? baseMessage,
|
20
|
+
value: value,
|
21
|
+
};
|
22
|
+
}
|
23
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXGreaterThanValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
24
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXGreaterThanValidationRule }); }
|
25
|
+
}
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXGreaterThanValidationRule, decorators: [{
|
27
|
+
type: Injectable
|
28
|
+
}] });
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JlYXRlci10aGFuLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9jb3JlL3ZhbGlkYXRpb24vc3JjL2xpYi9ydWxlcy9ncmVhdGVyLXRoYW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEscUNBQXFDO0FBQ3JDLE9BQU8sRUFBRSxNQUFNLEVBQUUsV0FBVyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBTWhELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7O0F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kZWZpbmVkKHZhbHVlKVxuICAgICAgICA/IHRydWVcbiAgICAgICAgOiBvcHRpb25zLmluY2x1c2l2ZVxuICAgICAgICA/IHZhbHVlID49IG9wdGlvbnMudmFsdWVcbiAgICAgICAgOiB2YWx1ZSA+IG9wdGlvbnMudmFsdWU7XG4gICAgY29uc3QgYmFzZU1lc3NhZ2UgPSBgVGhlIHZhbHVlIG11c3QgYmUgJHtcbiAgICAgIG9wdGlvbnMuaW5jbHVzaXZlID8gJ2dyZWF0ZXIgdGhhbiBvciBlcXVhbCB0bycgOiAnZ3JlYXRlciB0aGFuJ1xuICAgIH0gJHtvcHRpb25zLnZhbHVlfS5gO1xuXG4gICAgcmV0dXJuIHtcbiAgICAgIHJ1bGU6IHRoaXMubmFtZSxcbiAgICAgIHJlc3VsdDogaXNWYWxpZCxcbiAgICAgIG1lc3NhZ2U6IGlzVmFsaWQgPyAnJyA6IG9wdGlvbnM/Lm1lc3NhZ2UgPz8gYmFzZU1lc3NhZ2UsXG4gICAgICB2YWx1ZTogdmFsdWUsXG4gICAgfTtcbiAgfVxufVxuIl19
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// ax-max-length-validation-rule.ts
|
2
|
+
import { Injectable } from '@angular/core';
|
3
|
+
import * as i0 from "@angular/core";
|
4
|
+
export class AXLengthValidationRule {
|
5
|
+
get name() {
|
6
|
+
return 'length';
|
7
|
+
}
|
8
|
+
async validate(value, options) {
|
9
|
+
const isValid = value?.length >= options.min && value?.length <= options.max;
|
10
|
+
return {
|
11
|
+
rule: this.name,
|
12
|
+
result: isValid,
|
13
|
+
message: isValid
|
14
|
+
? null
|
15
|
+
: options?.message ??
|
16
|
+
`The value must be between ${options.min} and ${options.max} chars`,
|
17
|
+
value: value,
|
18
|
+
};
|
19
|
+
}
|
20
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXLengthValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
21
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXLengthValidationRule }); }
|
22
|
+
}
|
23
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXLengthValidationRule, decorators: [{
|
24
|
+
type: Injectable
|
25
|
+
}] });
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGVuZ3RoLXJ1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvdmFsaWRhdGlvbi9zcmMvbGliL3J1bGVzL2xlbmd0aC1ydWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLG1DQUFtQztBQUNuQyxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOztBQW1CM0MsTUFBTSxPQUFPLHNCQUFzQjtJQUNqQyxJQUFJLElBQUk7UUFDTixPQUFPLFFBQVEsQ0FBQztJQUNsQixDQUFDO0lBRUQsS0FBSyxDQUFDLFFBQVEsQ0FDWixLQUFhLEVBQ2IsT0FBc0M7UUFFdEMsTUFBTSxPQUFPLEdBQ1gsS0FBSyxFQUFFLE1BQU0sSUFBSSxPQUFPLENBQUMsR0FBRyxJQUFJLEtBQUssRUFBRSxNQUFNLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQztRQUMvRCxPQUFPO1lBQ0wsSUFBSSxFQUFFLElBQUksQ0FBQyxJQUFJO1lBQ2YsTUFBTSxFQUFFLE9BQU87WUFDZixPQUFPLEVBQUUsT0FBTztnQkFDZCxDQUFDLENBQUMsSUFBSTtnQkFDTixDQUFDLENBQUMsT0FBTyxFQUFFLE9BQU87b0JBQ2hCLDZCQUE2QixPQUFPLENBQUMsR0FBRyxRQUFRLE9BQU8sQ0FBQyxHQUFHLFFBQVE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UHJvbWlzZTxBWFZhbGlkYXRpb25SdWxlUmVzdWx0PiB7XG4gICAgY29uc3QgaXNWYWxpZCA9XG4gICAgICB2YWx1ZT8ubGVuZ3RoID49IG9wdGlvbnMubWluICYmIHZhbHVlPy5sZW5ndGggPD0gb3B0aW9ucy5tYXg7XG4gICAgcmV0dXJuIHtcbiAgICAgIHJ1bGU6IHRoaXMubmFtZSxcbiAgICAgIHJlc3VsdDogaXNWYWxpZCxcbiAgICAgIG1lc3NhZ2U6IGlzVmFsaWRcbiAgICAgICAgPyBudWxsXG4gICAgICAgIDogb3B0aW9ucz8ubWVzc2FnZSA/P1xuICAgICAgICAgIGBUaGUgdmFsdWUgbXVzdCBiZSBiZXR3ZWVuICR7b3B0aW9ucy5taW59IGFuZCAke29wdGlvbnMubWF4fSBjaGFyc2AsXG4gICAgICB2YWx1ZTogdmFsdWUsXG4gICAgfTtcbiAgfVxufVxuIl19
|
@@ -0,0 +1,29 @@
|
|
1
|
+
// ax-less-than-validation-rule.ts
|
2
|
+
import { isNull, isUndefined } from 'lodash-es';
|
3
|
+
import { Injectable } from '@angular/core';
|
4
|
+
import * as i0 from "@angular/core";
|
5
|
+
export class AXLessThanValidationRule {
|
6
|
+
get name() {
|
7
|
+
return 'lessThan';
|
8
|
+
}
|
9
|
+
async validate(value, options) {
|
10
|
+
const isValid = isNull(value) || isUndefined(value)
|
11
|
+
? true
|
12
|
+
: options.inclusive
|
13
|
+
? value <= options.value
|
14
|
+
: value < options.value;
|
15
|
+
const baseMessage = `The value must be ${options.inclusive ? 'less than or equal to' : 'less than'} ${options.value}.`;
|
16
|
+
return {
|
17
|
+
rule: this.name,
|
18
|
+
result: isValid,
|
19
|
+
message: isValid ? '' : options?.message ?? baseMessage,
|
20
|
+
value: value,
|
21
|
+
};
|
22
|
+
}
|
23
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXLessThanValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
24
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXLessThanValidationRule }); }
|
25
|
+
}
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXLessThanValidationRule, decorators: [{
|
27
|
+
type: Injectable
|
28
|
+
}] });
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGVzcy10aGFuLXJ1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvdmFsaWRhdGlvbi9zcmMvbGliL3J1bGVzL2xlc3MtdGhhbi1ydWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGtDQUFrQztBQUNsQyxPQUFPLEVBQUUsTUFBTSxFQUFFLFdBQVcsRUFBRSxNQUFNLFdBQVcsQ0FBQztBQU1oRCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOztBQWUzQyxNQUFNLE9BQU8sd0JBQXdCO0lBQ25DLElBQUksSUFBSTtRQUNOLE9BQU8sVUFBVSxDQUFDO0lBQ3BCLENBQUM7SUFFRCxLQUFLLENBQUMsUUFBUSxDQUNaLEtBQWEsRUFDYixPQUF3QztRQUV4QyxNQUFNLE9BQU8sR0FDWCxNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksV0FBVyxDQUFDLEtBQUssQ0FBQztZQUNqQyxDQUFDLENBQUMsSUFBSTtZQUNOLENBQUMsQ0FBQyxPQUFPLENBQUMsU0FBUztnQkFDbkIsQ0FBQyxDQUFDLEtBQUssSUFBSSxPQUFPLENBQUMsS0FBSztnQkFDeEIsQ0FBQyxDQUFDLEtBQUssR0FBRyxPQUFPLENBQUMsS0FBSyxDQUFDO1FBQzVCLE1BQU0sV0FBVyxHQU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zYWdlLFxuICAgICAgdmFsdWU6IHZhbHVlLFxuICAgIH07XG4gIH1cbn1cbiJdfQ==
|
@@ -0,0 +1,27 @@
|
|
1
|
+
// ax-max-length-validation-rule.ts
|
2
|
+
import { isEmpty } from 'lodash-es';
|
3
|
+
import { Injectable } from '@angular/core';
|
4
|
+
import * as i0 from "@angular/core";
|
5
|
+
export class AXMaxLengthValidationRule {
|
6
|
+
get name() {
|
7
|
+
return 'maxLength';
|
8
|
+
}
|
9
|
+
async validate(value, options) {
|
10
|
+
const isValid = isEmpty(value) ? true : value?.length <= options.value;
|
11
|
+
return {
|
12
|
+
rule: this.name,
|
13
|
+
result: isValid,
|
14
|
+
message: isValid
|
15
|
+
? ''
|
16
|
+
: options?.message ??
|
17
|
+
`The value must not exceed ${options.value} characters.`,
|
18
|
+
value: value,
|
19
|
+
};
|
20
|
+
}
|
21
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXMaxLengthValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
22
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXMaxLengthValidationRule }); }
|
23
|
+
}
|
24
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXMaxLengthValidationRule, decorators: [{
|
25
|
+
type: Injectable
|
26
|
+
}] });
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWF4bGVuZ3RoLXJ1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvdmFsaWRhdGlvbi9zcmMvbGliL3J1bGVzL21heGxlbmd0aC1ydWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLG1DQUFtQztBQUNuQyx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HVlfSBjaGFyYWN0ZXJzLmAsXG4gICAgICB2YWx1ZTogdmFsdWUsXG4gICAgfTtcbiAgfVxufVxuIl19
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { isEmpty } from 'lodash-es';
|
2
|
+
import { Injectable } from '@angular/core';
|
3
|
+
import * as i0 from "@angular/core";
|
4
|
+
export class AXMinLengthValidationRule {
|
5
|
+
get name() {
|
6
|
+
return 'minLength';
|
7
|
+
}
|
8
|
+
async validate(value, options) {
|
9
|
+
const isValid = isEmpty(value) ? true : value?.length >= options.value;
|
10
|
+
return {
|
11
|
+
rule: this.name,
|
12
|
+
result: isValid,
|
13
|
+
message: isValid
|
14
|
+
? ''
|
15
|
+
: options?.message ??
|
16
|
+
`The value must be at least ${options.value} characters long.`,
|
17
|
+
value: value,
|
18
|
+
};
|
19
|
+
}
|
20
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXMinLengthValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
21
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXMinLengthValidationRule }); }
|
22
|
+
}
|
23
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXMinLengthValidationRule, decorators: [{
|
24
|
+
type: Injectable
|
25
|
+
}] });
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlubGVuZ3RoLXJ1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvdmFsaWRhdGlvbi9zcmMvbGliL3J1bGVzL21pbmxlbmd0aC1ydWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTS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xuIl19
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { isEmpty, isString } from 'lodash-es';
|
2
|
+
import { Injectable, inject } from '@angular/core';
|
3
|
+
import { AXTranslationService } from '@acorex/core/translation';
|
4
|
+
import * as i0 from "@angular/core";
|
5
|
+
export class AXRegexValidationRule {
|
6
|
+
constructor() {
|
7
|
+
this.traslationService = inject(AXTranslationService);
|
8
|
+
}
|
9
|
+
get name() {
|
10
|
+
return 'regex';
|
11
|
+
}
|
12
|
+
async validate(value, options) {
|
13
|
+
// Convert string pattern to RegExp if necessary
|
14
|
+
const regexPattern = typeof options.pattern === 'string'
|
15
|
+
? new RegExp(options.pattern)
|
16
|
+
: options.pattern;
|
17
|
+
if (!value || (isString(value) && isEmpty(value.trim()))) {
|
18
|
+
return {
|
19
|
+
rule: this.name,
|
20
|
+
result: true,
|
21
|
+
message: null,
|
22
|
+
value: value,
|
23
|
+
};
|
24
|
+
}
|
25
|
+
else if (!isString(value)) {
|
26
|
+
return {
|
27
|
+
rule: this.name,
|
28
|
+
result: false,
|
29
|
+
message: `${value} is not string value.`,
|
30
|
+
value: value,
|
31
|
+
};
|
32
|
+
}
|
33
|
+
const isValid = regexPattern.test(value);
|
34
|
+
const translatedMessage = await this.traslationService.translateAsync(options?.message ??
|
35
|
+
`The value does not match the pattern ${regexPattern}.`, { params: { title: options?.['title'] } });
|
36
|
+
return {
|
37
|
+
rule: this.name,
|
38
|
+
result: isValid,
|
39
|
+
message: isValid ? null : translatedMessage,
|
40
|
+
value: value,
|
41
|
+
};
|
42
|
+
}
|
43
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXRegexValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
44
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXRegexValidationRule }); }
|
45
|
+
}
|
46
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXRegexValidationRule, decorators: [{
|
47
|
+
type: Injectable
|
48
|
+
}] });
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVnZXgtcnVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS92YWxpZGF0aW9uL3NyYy9saWIvcnVsZXMvcmVnZXgtcnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLFdBQVcsQ0FBQztBQU05QyxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUNuRCxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQzs7QUFjaEUsTUFBTSxPQUFPLHFCQUFxQjtJQURsQztRQUVVLHNCQUFpQixHQUFHLE1BQU0sQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO0tBNkMxRDtJQTNDQyxJQUFJLElBQUk7UUFDTixPQUFPLE9BQU8sQ0FBQztJQUNqQixDQUFDO0lBRUQsS0FBSyxDQUFDLFFBQVEsQ0FDWixLQUFhLEVBQ2IsT0FBcUM7UUFFckMsZ0RBQWdEO1FBQ2hELE1BQU0sWUFBWSxHQUNoQixPQUFPLE9BQU8sQ0FBQyxPQUFPLEtBQUssUUFBUTtZQUNqQyxDQUFDLENBQUMsSUFBSSxNQUFNLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQztZQUM3QixDQUFDLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQztRQUV0QixJQUFJLENBQUMsS0FBSyxJQUFJLENBQUMsUUFBUSxDQUFDLEtBQUssQ0FBQyxJQUFJLE9BQU8sQ0FBQyxLQUFLLEN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cbiAgICAgIG9wdGlvbnM/Lm1lc3NhZ2UgPz9cbiAgICAgICAgYFRoZSB2YWx1ZSBkb2VzIG5vdCBtYXRjaCB0aGUgcGF0dGVybiAke3JlZ2V4UGF0dGVybn0uYCxcbiAgICAgIHsgcGFyYW1zOiB7IHRpdGxlOiBvcHRpb25zPy5bJ3RpdGxlJ10gfSB9XG4gICAgKTtcbiAgICByZXR1cm4ge1xuICAgICAgcnVsZTogdGhpcy5uYW1lLFxuICAgICAgcmVzdWx0OiBpc1ZhbGlkLFxuICAgICAgbWVzc2FnZTogaXNWYWxpZCA/IG51bGwgOiB0cmFuc2xhdGVkTWVzc2FnZSxcbiAgICAgIHZhbHVlOiB2YWx1ZSxcbiAgICB9O1xuICB9XG59XG4iXX0=
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { find, isArray, isEmpty, isNull, isNumber, isString, isUndefined, } from 'lodash-es';
|
2
|
+
import { Injectable, inject } from '@angular/core';
|
3
|
+
import { AXTranslationService } from '@acorex/core/translation';
|
4
|
+
import * as i0 from "@angular/core";
|
5
|
+
export class AXRequiredValidationRule {
|
6
|
+
constructor() {
|
7
|
+
this.traslationService = inject(AXTranslationService);
|
8
|
+
}
|
9
|
+
get name() {
|
10
|
+
return 'required';
|
11
|
+
}
|
12
|
+
async validate(value, options) {
|
13
|
+
const rules = [
|
14
|
+
{ test: (val) => isNull(val) || isUndefined(val) },
|
15
|
+
{ test: (val) => isString(val) && isEmpty(val.trim()) },
|
16
|
+
{ test: (val) => isNumber(val) && isNaN(val) },
|
17
|
+
{ test: (val) => isArray(val) && isEmpty(val) },
|
18
|
+
];
|
19
|
+
const failedRule = find(rules, (rule) => rule.test(value));
|
20
|
+
const isValid = !failedRule;
|
21
|
+
const translatedMessage = await this.traslationService.translateAsync('validation.messages.required', { params: { title: options?.['title'] } });
|
22
|
+
const message = failedRule ? options?.message ?? translatedMessage : null;
|
23
|
+
return {
|
24
|
+
rule: this.name,
|
25
|
+
result: isValid,
|
26
|
+
message: message,
|
27
|
+
value,
|
28
|
+
};
|
29
|
+
}
|
30
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXRequiredValidationRule, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
31
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXRequiredValidationRule }); }
|
32
|
+
}
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXRequiredValidationRule, decorators: [{
|
34
|
+
type: Injectable
|
35
|
+
}] });
|
36
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVxdWlyZWQtcnVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS92YWxpZGF0aW9uL3NyYy9saWIvcnVsZXMvcmVxdWlyZWQtcnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsSUFBSSxFQUNKLE9BQU8sRUFDUCxPQUFPLEVBQ1AsTUFBTSxFQUNOLFFBQVEsRUFDUixRQUFRLEVBQ1IsV0FBVyxHQUNaLE1BQU0sV0FBVyxDQUFDO0FBTW5CLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ25ELE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLDBCQUEwQixDQUFDOztBQWNoRSxNQUFNLE9BQU8sd0JBQXdCO0lBRHJDO1FBRVUsc0JBQWlCLEdBQUcsTUFBTSxDQUFDLG9CQUFvQixDQUFDLENBQUM7S0FnQzFEO0lBOUJDLElBQUksSUFBSTtRQUNOLE9BQU8sVUFBVSxDQUFDO0lBQ3BCLENBQUM7SUFFRCxLQU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3QgaXNWYWxpZCA9ICFmYWlsZWRSdWxlO1xuICAgIGNvbnN0IHRyYW5zbGF0ZWRNZXNzYWdlID0gYXdhaXQgdGhpcy50cmFzbGF0aW9uU2VydmljZS50cmFuc2xhdGVBc3luYyhcbiAgICAgICd2YWxpZGF0aW9uLm1lc3NhZ2VzLnJlcXVpcmVkJyxcbiAgICAgIHsgcGFyYW1zOiB7IHRpdGxlOiBvcHRpb25zPy5bJ3RpdGxlJ10gfSB9XG4gICAgKTtcbiAgICBjb25zdCBtZXNzYWdlID0gZmFpbGVkUnVsZSA/IG9wdGlvbnM/Lm1lc3NhZ2UgPz8gdHJhbnNsYXRlZE1lc3NhZ2UgOiBudWxsO1xuXG4gICAgcmV0dXJuIHtcbiAgICAgIHJ1bGU6IHRoaXMubmFtZSxcbiAgICAgIHJlc3VsdDogaXNWYWxpZCxcbiAgICAgIG1lc3NhZ2U6IG1lc3NhZ2UsXG4gICAgICB2YWx1ZSxcbiAgICB9O1xuICB9XG59XG4iXX0=
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
2
|
+
export const AX_VALIDATION_CONFIG = new InjectionToken('AX_VALIDATION_CONFIG', {
|
3
|
+
providedIn: 'root',
|
4
|
+
factory: () => {
|
5
|
+
return AXValidationDefaultConfig;
|
6
|
+
},
|
7
|
+
});
|
8
|
+
export const AXValidationDefaultConfig = {
|
9
|
+
rules: {
|
10
|
+
email: {
|
11
|
+
rule: 'regex',
|
12
|
+
options: {
|
13
|
+
pattern: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
14
|
+
message: 'validation.messages.email',
|
15
|
+
},
|
16
|
+
},
|
17
|
+
phone: {
|
18
|
+
rule: 'regex',
|
19
|
+
options: {
|
20
|
+
pattern: /^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$/,
|
21
|
+
message: 'validation.messages.phone',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
},
|
25
|
+
};
|
26
|
+
export function validationConfig(config = {}) {
|
27
|
+
const result = {
|
28
|
+
...AXValidationDefaultConfig,
|
29
|
+
...config,
|
30
|
+
};
|
31
|
+
return result;
|
32
|
+
}
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5jb25maWcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvdmFsaWRhdGlvbi9zcmMvbGliL3ZhbGlkYXRpb24uY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFpQi9DLE1BQU0sQ0FBQyxNQUFNLG9CQUFvQixHQUFHLElBQUksY0FBYyxDQUNwRCxzQkFBc0IsRUFDdEI7SUFDRSxVQUFVLEVBQUUsTUFBTTtJQUNsQixPQUFPLEVBQUUsR0FBRyxFQUFFO1FBQ1osT0FBTyx5QkFBeUIsQ0FBQztJQUNuQyxDQUFDO0NBQ0YsQ0FDRixDQUFDO0FBRUYsTUFBTSxDQUFDLE1BQU0seUJBQXlCLEdBQXVCO0lBQzNELEtBQUssRUFBRTtRQUNMLEtBQUssRUFBRTtZQUNMLElBQUksRUFBRSxPQUFPO1lBQ2IsT0FBTyxFQUFFO2dCQUNQLE9BQU8sRUFDTCx1SkFBdUo7Z0JBQ3pKLE9BQU8sRUFBRSwyQkFBMkI7YUFDckM7U0FDRjtRQUNELEtBQUssRUFBRTtZQUNMLElBQUksRUFBRSxPQUFPO1lBQ2IsT0FBTyxFQUFFO2dCQUNQLE9BQU8sRUFBRSw4Q0FBOEM7Z0JBQ3ZELE9BQU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O1xuICByZXR1cm4gcmVzdWx0O1xufVxuIl19
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import { Inject, NgModule, } from '@angular/core';
|
2
|
+
import { AXValidationRegistryService } from './validation.service';
|
3
|
+
import { AXRegexValidationRule } from './rules/regex-rule';
|
4
|
+
import { AXRequiredValidationRule } from './rules/required-rule';
|
5
|
+
import { AXCallbackValidationRule } from './rules/callback-rule';
|
6
|
+
import { AXMinLengthValidationRule } from './rules/minlength-rule';
|
7
|
+
import { AXMaxLengthValidationRule } from './rules/maxlength-rule';
|
8
|
+
import { AXLengthValidationRule } from './rules/length-rule';
|
9
|
+
import { AXEqualValidationRule } from './rules/equal-rule';
|
10
|
+
import { AXLessThanValidationRule } from './rules/less-than-rule';
|
11
|
+
import { AXGreaterThanValidationRule } from './rules/greater-than';
|
12
|
+
import { AXBetweenValidationRule } from './rules/between-rule';
|
13
|
+
import * as i0 from "@angular/core";
|
14
|
+
const BUILT_IN_RULES = [
|
15
|
+
AXRequiredValidationRule,
|
16
|
+
AXRegexValidationRule,
|
17
|
+
AXRequiredValidationRule,
|
18
|
+
AXCallbackValidationRule,
|
19
|
+
//
|
20
|
+
AXMinLengthValidationRule,
|
21
|
+
AXMaxLengthValidationRule,
|
22
|
+
AXLengthValidationRule,
|
23
|
+
//
|
24
|
+
AXEqualValidationRule,
|
25
|
+
AXLessThanValidationRule,
|
26
|
+
AXGreaterThanValidationRule,
|
27
|
+
AXBetweenValidationRule,
|
28
|
+
];
|
29
|
+
export class AXValidationModule {
|
30
|
+
static forRoot(configs) {
|
31
|
+
return {
|
32
|
+
ngModule: AXValidationModule,
|
33
|
+
providers: [
|
34
|
+
...(configs?.rules || []),
|
35
|
+
{
|
36
|
+
provide: 'AXValidationModuleFactory',
|
37
|
+
useFactory: (pluginRegistry) => () => {
|
38
|
+
pluginRegistry.register(...[...BUILT_IN_RULES, ...(configs?.rules || [])]);
|
39
|
+
},
|
40
|
+
deps: [AXValidationRegistryService],
|
41
|
+
multi: true,
|
42
|
+
},
|
43
|
+
],
|
44
|
+
};
|
45
|
+
}
|
46
|
+
static forChild(configs) {
|
47
|
+
return {
|
48
|
+
ngModule: AXValidationModule,
|
49
|
+
providers: [
|
50
|
+
...(configs?.rules || []),
|
51
|
+
{
|
52
|
+
provide: 'AXValidationModuleFactory',
|
53
|
+
useFactory: (pluginRegistry) => () => {
|
54
|
+
pluginRegistry.register(...[...BUILT_IN_RULES, ...(configs?.rules || [])]);
|
55
|
+
},
|
56
|
+
deps: [AXValidationRegistryService],
|
57
|
+
multi: true,
|
58
|
+
},
|
59
|
+
],
|
60
|
+
};
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* @ignore
|
64
|
+
*/
|
65
|
+
constructor(instances) {
|
66
|
+
instances.forEach((f) => {
|
67
|
+
f();
|
68
|
+
});
|
69
|
+
}
|
70
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXValidationModule, deps: [{ token: 'AXValidationModuleFactory' }], target: i0.ɵɵFactoryTarget.NgModule }); }
|
71
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.2", ngImport: i0, type: AXValidationModule }); }
|
72
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXValidationModule, providers: [...BUILT_IN_RULES] }); }
|
73
|
+
}
|
74
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXValidationModule, decorators: [{
|
75
|
+
type: NgModule,
|
76
|
+
args: [{
|
77
|
+
imports: [],
|
78
|
+
providers: [...BUILT_IN_RULES],
|
79
|
+
}]
|
80
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
81
|
+
type: Inject,
|
82
|
+
args: ['AXValidationModuleFactory']
|
83
|
+
}] }] });
|
84
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9u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3IoQEluamVjdCgnQVhWYWxpZGF0aW9uTW9kdWxlRmFjdG9yeScpIGluc3RhbmNlczogYW55W10pIHtcbiAgICBpbnN0YW5jZXMuZm9yRWFjaCgoZikgPT4ge1xuICAgICAgZigpO1xuICAgIH0pO1xuICB9XG59XG4iXX0=
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import { Injectable, Injector, inject } from '@angular/core';
|
2
|
+
import { AX_VALIDATION_CONFIG, } from './validation.config';
|
3
|
+
import { AXTranslationService } from '@acorex/core/translation';
|
4
|
+
import { merge } from 'lodash-es';
|
5
|
+
import * as i0 from "@angular/core";
|
6
|
+
import * as i1 from "@acorex/core/translation";
|
7
|
+
export class AXValidationRegistryService {
|
8
|
+
get customRules() {
|
9
|
+
return this.configs.rules;
|
10
|
+
}
|
11
|
+
constructor(injector) {
|
12
|
+
this.plugins = [];
|
13
|
+
this.configs = inject(AX_VALIDATION_CONFIG);
|
14
|
+
this.injector = injector;
|
15
|
+
}
|
16
|
+
register(...plugins) {
|
17
|
+
plugins.forEach((t) => {
|
18
|
+
const childInjector = Injector.create({
|
19
|
+
providers: [{ provide: t, useClass: t, deps: [] }],
|
20
|
+
parent: this.injector,
|
21
|
+
});
|
22
|
+
const v = childInjector.get(t);
|
23
|
+
if (v && !this.plugins.some((p) => p.name == v.name)) {
|
24
|
+
this.plugins.push(v);
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
28
|
+
get(ruleName) {
|
29
|
+
return this.plugins.find((c) => c.name == ruleName);
|
30
|
+
}
|
31
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXValidationRegistryService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
32
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXValidationRegistryService, providedIn: 'root' }); }
|
33
|
+
}
|
34
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXValidationRegistryService, decorators: [{
|
35
|
+
type: Injectable,
|
36
|
+
args: [{
|
37
|
+
providedIn: 'root',
|
38
|
+
}]
|
39
|
+
}], ctorParameters: () => [{ type: i0.Injector }] });
|
40
|
+
export class AXValidationService {
|
41
|
+
constructor(pluginRegistry, translationService) {
|
42
|
+
this.pluginRegistry = pluginRegistry;
|
43
|
+
this.translationService = translationService;
|
44
|
+
}
|
45
|
+
async validate(ruleName, value, options) {
|
46
|
+
const customRule = this.pluginRegistry.customRules[ruleName];
|
47
|
+
const validator = this.pluginRegistry.get(ruleName);
|
48
|
+
if (!validator && !customRule) {
|
49
|
+
return {
|
50
|
+
rule: ruleName,
|
51
|
+
result: false,
|
52
|
+
message: await this.translationService.translateAsync('validation.messages.invalid-rull-name', { params: { name: ruleName } }),
|
53
|
+
value,
|
54
|
+
};
|
55
|
+
}
|
56
|
+
if (options?.message) {
|
57
|
+
options.message = await this.translationService.translateAsync(options.message);
|
58
|
+
}
|
59
|
+
//
|
60
|
+
if (validator)
|
61
|
+
return validator.validate(value, options);
|
62
|
+
else {
|
63
|
+
return this.validate(customRule.rule, value, merge(options, customRule.options));
|
64
|
+
}
|
65
|
+
}
|
66
|
+
ruleFor(value) {
|
67
|
+
return new AXValidationRuleChain(this, value);
|
68
|
+
}
|
69
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXValidationService, deps: [{ token: AXValidationRegistryService }, { token: i1.AXTranslationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
70
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXValidationService, providedIn: 'root' }); }
|
71
|
+
}
|
72
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXValidationService, decorators: [{
|
73
|
+
type: Injectable,
|
74
|
+
args: [{ providedIn: 'root' }]
|
75
|
+
}], ctorParameters: () => [{ type: AXValidationRegistryService }, { type: i1.AXTranslationService }] });
|
76
|
+
class AXValidationRuleChain {
|
77
|
+
constructor(validationService, initialValue) {
|
78
|
+
this.validationService = validationService;
|
79
|
+
this.initialValue = initialValue;
|
80
|
+
this.rules = [];
|
81
|
+
this.validationSummary = { result: true, rules: [] };
|
82
|
+
}
|
83
|
+
addRule(name, options) {
|
84
|
+
this.rules.push({ name, options });
|
85
|
+
return this;
|
86
|
+
}
|
87
|
+
async validate() {
|
88
|
+
for (const rule of this.rules) {
|
89
|
+
const result = await this.validationService.validate(rule.name, this.initialValue, rule.options);
|
90
|
+
this.validationSummary.rules.push(result);
|
91
|
+
if (!result.result) {
|
92
|
+
this.validationSummary.result = false;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
return this.validationSummary;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9jb3JlL3ZhbGlkYXRpb24vc3JjL2xpYi92YWxpZGF0aW9uLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxRQUFRLEVBQUUsTUFBTSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBUTdELE9BQU8sRUFFTCxvQkFBb0IsR0FDckIsTUFBTSxxQkFBcUIsQ0FBQztBQUM3QixPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsS0FBSyxFQUFFLE1BQU0sV0FBVyxDQUFDOzs7QUFLbEMsTUFBTSxPQUFPLDJCQUEyQjtJQUt0QyxJQUFXLFdBQVc7UUF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