@skyux/validation 6.0.1 → 6.2.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/documentation.json +266 -97
- package/esm2020/index.mjs +2 -1
- package/esm2020/lib/modules/url-validation/url-validation-options.mjs +2 -0
- package/esm2020/lib/modules/url-validation/url-validation.directive.mjs +25 -15
- package/esm2020/lib/modules/validation/validation.mjs +19 -3
- package/esm2020/lib/modules/validators/validators.mjs +29 -19
- package/fesm2015/skyux-validation.mjs +69 -33
- package/fesm2015/skyux-validation.mjs.map +1 -1
- package/fesm2020/skyux-validation.mjs +69 -33
- package/fesm2020/skyux-validation.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/lib/modules/url-validation/url-validation-options.d.ts +9 -0
- package/lib/modules/url-validation/url-validation.directive.d.ts +11 -6
- package/lib/modules/validation/validation.d.ts +2 -1
- package/lib/modules/validators/validators.d.ts +12 -6
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skyux-validation.mjs","sources":["../../../../../libs/components/validation/src/lib/modules/validation/validation.ts","../../../../../libs/components/validation/src/lib/modules/email-validation/email-validation.directive.ts","../../../../../libs/components/validation/src/lib/modules/email-validation/email-validation.module.ts","../../../../../libs/components/validation/src/lib/modules/url-validation/url-validation.directive.ts","../../../../../libs/components/validation/src/lib/modules/url-validation/url-validation.module.ts","../../../../../libs/components/validation/src/lib/modules/validators/validators.ts","../../../../../libs/components/validation/src/skyux-validation.ts"],"sourcesContent":["export abstract class SkyValidation {\n public static isEmail(emailAddress: string): boolean {\n // The regex was obtained from http://emailregex.com/\n // which claims to correctly handle ~99% of all email addresses.\n const regex =\n /^(([^<>()[\\]\\\\.,;:\\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,}))$/;\n return regex.test(emailAddress);\n }\n\n public static isUrl(url: string): boolean {\n const regex = /^((http|https):\\/\\/)?([\\w-]+\\.)+[\\w-]+/i;\n return regex.test(url);\n }\n}\n","import { Directive, forwardRef } from '@angular/core';\nimport { AbstractControl, NG_VALIDATORS, Validator } from '@angular/forms';\n\nimport { SkyValidation } from '../validation/validation';\n\nconst SKY_EMAIL_VALIDATION_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyEmailValidationDirective),\n multi: true,\n};\n\n/**\n * Creates an input to validate email addresses. Place this attribute on an `input` element.\n * If users enter values that are not valid email addresses, an error message appears.\n * The directive uses `NgModel` to bind data.\n */\n@Directive({\n selector: '[skyEmailValidation]',\n providers: [SKY_EMAIL_VALIDATION_VALIDATOR],\n})\nexport class SkyEmailValidationDirective implements Validator {\n public validate(control: AbstractControl): { [key: string]: any } {\n const value = control.value;\n\n if (!value) {\n return;\n }\n\n if (!this.emailIsValid(value)) {\n return {\n skyEmail: {\n invalid: control.value,\n },\n };\n }\n }\n\n public emailIsValid(email: string): boolean {\n return SkyValidation.isEmail(email);\n }\n}\n","import { NgModule } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\n\nimport { SkyEmailValidationDirective } from './email-validation.directive';\n\n@NgModule({\n declarations: [SkyEmailValidationDirective],\n imports: [FormsModule],\n exports: [SkyEmailValidationDirective],\n})\nexport class SkyEmailValidationModule {}\n","import { Directive, forwardRef } from '@angular/core';\nimport { AbstractControl, NG_VALIDATORS, Validator } from '@angular/forms';\n\nimport { SkyValidation } from '../validation/validation';\n\nconst SKY_URL_VALIDATION_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyUrlValidationDirective),\n multi: true,\n};\n\n/**\n * Creates an input to validate URLs. Place this attribute on an `input` element.\n * If users enters values that are not valid URLs, an error message appears.\n * This directive uses `NgModel` to bind data.\n */\n@Directive({\n selector: '[skyUrlValidation]',\n providers: [SKY_URL_VALIDATION_VALIDATOR],\n})\nexport class SkyUrlValidationDirective implements Validator {\n public validate(control: AbstractControl): { [key: string]: any } {\n const value = control.value;\n\n if (!value) {\n return;\n }\n\n if (!this.urlIsValid(value)) {\n return {\n skyUrl: {\n invalid: control.value,\n },\n };\n }\n }\n\n public urlIsValid(url: string): boolean {\n return SkyValidation.isUrl(url);\n }\n}\n","import { NgModule } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\n\nimport { SkyUrlValidationDirective } from './url-validation.directive';\n\n@NgModule({\n declarations: [SkyUrlValidationDirective],\n imports: [FormsModule],\n exports: [SkyUrlValidationDirective],\n})\nexport class SkyUrlValidationModule {}\n","import { AbstractControl, ValidationErrors } from '@angular/forms';\n\nimport { SkyValidation } from '../validation/validation';\n\n// Need to add the following to classes which contain static methods.\n// See: https://github.com/ng-packagr/ng-packagr/issues/641\n// @dynamic\nexport class SkyValidators {\n /**\n * Validates email addresses in reactive forms. Add this validator directly to the form control\n * model in the component class. If users enter values that are not valid email addresses, the\n * validator throws an error. Since this is a sync validator, it returns a set of validation\n * errors or `undefined` immediately when users enter values.\n * @param control\n */\n public static email(control: AbstractControl): ValidationErrors | null {\n const value = control.value;\n\n if (!value) {\n return undefined;\n }\n\n return SkyValidation.isEmail(value)\n ? undefined\n : { skyEmail: { invalid: value } };\n }\n\n /**\n * Validates URLs in reactive forms. Add this validator directly to the form control model in\n * the component class. If users enter values that are not valid URLs, the validator throws an\n * error. Since this is a sync validator, it returns a set of validation errors or `undefined`\n * immediately when users enter values.\n * @param control\n */\n public static url(control: AbstractControl): ValidationErrors | null {\n const value = control.value;\n\n if (!value) {\n return undefined;\n }\n\n return SkyValidation.isUrl(value)\n ? undefined\n : { skyUrl: { invalid: value } };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAAsB,aAAa,CAAA;IAC1B,OAAO,OAAO,CAAC,YAAoB,EAAA;;;QAGxC,MAAM,KAAK,GACT,sJAAsJ,CAAC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ACA;MACa,aAAa,CAAA;AACxB;;;;;;AAMG;IACI,OAAO,KAAK,CAAC,OAAwB,EAAA;AAC1C,QAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE5B,IAAI,CAAC,KAAK,EAAE;AACV,YAAA,OAAO,SAAS,CAAC;AAClB,SAAA;AAED,QAAA,OAAO,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC;AACjC,cAAE,SAAS;cACT,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC;KACtC;AAED;;;;;;AAMG;IACI,OAAO,GAAG,CAAC,OAAwB,EAAA;AACxC,QAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE5B,IAAI,CAAC,KAAK,EAAE;AACV,YAAA,OAAO,SAAS,CAAC;AAClB,SAAA;AAED,QAAA,OAAO,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC;AAC/B,cAAE,SAAS;cACT,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC;KACpC;AACF;;AC7CD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"skyux-validation.mjs","sources":["../../../../../libs/components/validation/src/lib/modules/validation/validation.ts","../../../../../libs/components/validation/src/lib/modules/email-validation/email-validation.directive.ts","../../../../../libs/components/validation/src/lib/modules/email-validation/email-validation.module.ts","../../../../../libs/components/validation/src/lib/modules/url-validation/url-validation.directive.ts","../../../../../libs/components/validation/src/lib/modules/url-validation/url-validation.module.ts","../../../../../libs/components/validation/src/lib/modules/validators/validators.ts","../../../../../libs/components/validation/src/skyux-validation.ts"],"sourcesContent":["import isURL from 'validator/es/lib/isURL';\n\nimport { SkyUrlValidationOptions } from '../url-validation/url-validation-options';\n\nexport abstract class SkyValidation {\n public static isEmail(emailAddress: string): boolean {\n // The regex was obtained from http://emailregex.com/\n // which claims to correctly handle ~99% of all email addresses.\n const regex =\n /^(([^<>()[\\]\\\\.,;:\\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,}))$/;\n return regex.test(emailAddress);\n }\n\n public static isUrl(\n value: unknown,\n options?: SkyUrlValidationOptions\n ): boolean {\n if (typeof value !== 'string') {\n return false;\n }\n\n const url: string = value;\n\n const regex = /^((http|https):\\/\\/)?([\\w-]+\\.)+[\\w-]+/i;\n if (options) {\n switch (options.rulesetVersion) {\n case 1:\n return regex.test(url);\n case 2:\n // we are using the `validator` package's default options\n return isURL(url);\n }\n } else {\n return regex.test(url);\n }\n }\n}\n","import { Directive, forwardRef } from '@angular/core';\nimport { AbstractControl, NG_VALIDATORS, Validator } from '@angular/forms';\n\nimport { SkyValidation } from '../validation/validation';\n\nconst SKY_EMAIL_VALIDATION_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyEmailValidationDirective),\n multi: true,\n};\n\n/**\n * Creates an input to validate email addresses. Place this attribute on an `input` element.\n * If users enter values that are not valid email addresses, an error message appears.\n * The directive uses `NgModel` to bind data.\n */\n@Directive({\n selector: '[skyEmailValidation]',\n providers: [SKY_EMAIL_VALIDATION_VALIDATOR],\n})\nexport class SkyEmailValidationDirective implements Validator {\n public validate(control: AbstractControl): { [key: string]: any } {\n const value = control.value;\n\n if (!value) {\n return;\n }\n\n if (!this.emailIsValid(value)) {\n return {\n skyEmail: {\n invalid: control.value,\n },\n };\n }\n }\n\n public emailIsValid(email: string): boolean {\n return SkyValidation.isEmail(email);\n }\n}\n","import { NgModule } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\n\nimport { SkyEmailValidationDirective } from './email-validation.directive';\n\n@NgModule({\n declarations: [SkyEmailValidationDirective],\n imports: [FormsModule],\n exports: [SkyEmailValidationDirective],\n})\nexport class SkyEmailValidationModule {}\n","import { Directive, Input, forwardRef } from '@angular/core';\nimport {\n AbstractControl,\n NG_VALIDATORS,\n ValidationErrors,\n Validator,\n} from '@angular/forms';\n\nimport { SkyValidation } from '../validation/validation';\n\nimport { SkyUrlValidationOptions } from './url-validation-options';\n\n// tslint:disable:no-forward-ref no-use-before-declare\nconst SKY_URL_VALIDATION_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyUrlValidationDirective),\n multi: true,\n};\n\n/**\n * Creates an input to validate URLs. Place this attribute on an `input` element.\n * If users enters values that are not valid URLs, an error message appears.\n * This directive uses `NgModel` to bind data.\n */\n@Directive({\n selector: '[skyUrlValidation]',\n providers: [SKY_URL_VALIDATION_VALIDATOR],\n})\nexport class SkyUrlValidationDirective implements Validator {\n /**\n * Specifies configuration options for the URL validation component.\n */\n @Input()\n public set skyUrlValidation(value: SkyUrlValidationOptions | undefined) {\n this._skyUrlValidationOptions = value;\n this._validatorChange();\n }\n\n private _skyUrlValidationOptions: SkyUrlValidationOptions | undefined;\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n private _validatorChange = () => {};\n\n public validate(control: AbstractControl): ValidationErrors | null {\n const value = control.value;\n\n if (!value) {\n return null;\n }\n\n return SkyValidation.isUrl(value, this._skyUrlValidationOptions)\n ? null\n : { skyUrl: { invalid: value } };\n }\n\n public registerOnValidatorChange(fn: () => void): void {\n this._validatorChange = fn;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\n\nimport { SkyUrlValidationDirective } from './url-validation.directive';\n\n@NgModule({\n declarations: [SkyUrlValidationDirective],\n imports: [FormsModule],\n exports: [SkyUrlValidationDirective],\n})\nexport class SkyUrlValidationModule {}\n","import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';\n\nimport { SkyUrlValidationOptions } from '../url-validation/url-validation-options';\nimport { SkyValidation } from '../validation/validation';\n\n// Need to add the following to classes which contain static methods.\n// See: https://github.com/ng-packagr/ng-packagr/issues/641\n// @dynamic\nexport class SkyValidators {\n /**\n * Validates email addresses in reactive forms. Add this validator directly to the form control\n * model in the component class. If users enter values that are not valid email addresses, the\n * validator throws an error. Since this is a sync validator, it returns a set of validation\n * errors or `null` immediately when users enter values.\n */\n public static email(control: AbstractControl): ValidationErrors | null {\n const value = control.value;\n\n if (!value) {\n return null;\n }\n\n return SkyValidation.isEmail(value)\n ? null\n : { skyEmail: { invalid: value } };\n }\n\n /**\n * Validates URLs in reactive forms. Add this validator directly to the form control model in\n * the component class. If users enter values that are not valid URLs, the validator throws an\n * error. Since this is a sync validator, it returns a set of validation errors or `null`\n * immediately when users enter values.\n */\n public static url(abstractControl: AbstractControl): ValidationErrors | null;\n\n /**\n * Validates URLs in reactive forms. Add this validator with ruleset parameters directly to\n * the form control model in the component class. If users enter values that are not valid\n * URLs, the validator throws an error. Since this is a sync validator, it returns a set of\n * validation errors or `null` immediately when users enter values.\n */\n public static url(\n skyUrlValidationOptions: SkyUrlValidationOptions\n ): ValidatorFn | null;\n\n public static url(\n value: AbstractControl | SkyUrlValidationOptions\n ): ValidatorFn | ValidationErrors | null {\n const typeTester = value as SkyUrlValidationOptions;\n if (typeTester.rulesetVersion === undefined) {\n // there are no SkyUrlValidationOptions passed in, so return ValidationErrors | null\n const abstractControl = value as AbstractControl;\n const abstractControlValue = abstractControl.value;\n if (!abstractControlValue) {\n return null;\n }\n return SkyValidation.isUrl(abstractControlValue)\n ? null\n : { skyUrl: { invalid: abstractControlValue } };\n } else {\n // there are SkyUrlValidationOptions passed in, so return ValidatorFn\n const skyUrlValidationOptions = value as SkyUrlValidationOptions;\n return (abstractControl: AbstractControl): ValidationErrors | null => {\n const abstractControlValue = abstractControl.value;\n if (!abstractControlValue) {\n return null;\n }\n\n return SkyValidation.isUrl(\n abstractControl.value,\n skyUrlValidationOptions\n )\n ? null\n : { skyUrl: { invalid: abstractControl.value } };\n };\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAIsB,aAAa,CAAA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,UAAU,GAAG,KAAgC,CAAC;AACpD,QAAA,IAAI,UAAU,CAAC,cAAc,KAAK,SAAS,EAAE;;YAE3C,MAAM,eAAe,GAAG,KAAwB,CAAC;AACjD,YAAA,MAAM,oBAAoB,GAAG,eAAe,CAAC,KAAK,CAAC;YACnD,IAAI,CAAC,oBAAoB,EAAE;AACzB,gBAAA,OAAO,IAAI,CAAC;AACb,aAAA;AACD,YAAA,OAAO,aAAa,CAAC,KAAK,CAAC,oBAAoB,CAAC;AAC9C,kBAAE,IAAI;kBACJ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,EAAE,CAAC;AACnD,SAAA;AAAM,aAAA;;YAEL,MAAM,uBAAuB,GAAG,KAAgC,CAAC;YACjE,OAAO,CAAC,eAAgC,KAA6B;AACnE,gBAAA,MAAM,oBAAoB,GAAG,eAAe,CAAC,KAAK,CAAC;gBACnD,IAAI,CAAC,oBAAoB,EAAE;AACzB,oBAAA,OAAO,IAAI,CAAC;AACb,iBAAA;gBAED,OAAO,aAAa,CAAC,KAAK,CACxB,eAAe,CAAC,KAAK,EACrB,uBAAuB,CACxB;AACC,sBAAE,IAAI;AACN,sBAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC;AACrD,aAAC,CAAC;AACH,SAAA;KACF;AACF;;AC7ED;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './lib/modules/email-validation/email-validation.module';
|
|
2
|
+
export * from './lib/modules/url-validation/url-validation-options';
|
|
2
3
|
export * from './lib/modules/url-validation/url-validation.module';
|
|
3
4
|
export * from './lib/modules/validation/validation';
|
|
4
5
|
export * from './lib/modules/validators/validators';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specifies options for the URL validator component.
|
|
3
|
+
*/
|
|
4
|
+
export interface SkyUrlValidationOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates the ruleset to use for URL validation. Ruleset 1 uses a regular expression and ruleset 2 uses the third-party [validator.js library](https://github.com/validatorjs/validator.js/).
|
|
7
|
+
*/
|
|
8
|
+
rulesetVersion: 1 | 2;
|
|
9
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AbstractControl, Validator } from '@angular/forms';
|
|
1
|
+
import { AbstractControl, ValidationErrors, Validator } from '@angular/forms';
|
|
2
|
+
import { SkyUrlValidationOptions } from './url-validation-options';
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
4
|
/**
|
|
4
5
|
* Creates an input to validate URLs. Place this attribute on an `input` element.
|
|
@@ -6,10 +7,14 @@ import * as i0 from "@angular/core";
|
|
|
6
7
|
* This directive uses `NgModel` to bind data.
|
|
7
8
|
*/
|
|
8
9
|
export declare class SkyUrlValidationDirective implements Validator {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Specifies configuration options for the URL validation component.
|
|
12
|
+
*/
|
|
13
|
+
set skyUrlValidation(value: SkyUrlValidationOptions | undefined);
|
|
14
|
+
private _skyUrlValidationOptions;
|
|
15
|
+
private _validatorChange;
|
|
16
|
+
validate(control: AbstractControl): ValidationErrors | null;
|
|
17
|
+
registerOnValidatorChange(fn: () => void): void;
|
|
13
18
|
static ɵfac: i0.ɵɵFactoryDeclaration<SkyUrlValidationDirective, never>;
|
|
14
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<SkyUrlValidationDirective, "[skyUrlValidation]", never, {}, {}, never>;
|
|
19
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<SkyUrlValidationDirective, "[skyUrlValidation]", never, { "skyUrlValidation": "skyUrlValidation"; }, {}, never>;
|
|
15
20
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { SkyUrlValidationOptions } from '../url-validation/url-validation-options';
|
|
1
2
|
export declare abstract class SkyValidation {
|
|
2
3
|
static isEmail(emailAddress: string): boolean;
|
|
3
|
-
static isUrl(
|
|
4
|
+
static isUrl(value: unknown, options?: SkyUrlValidationOptions): boolean;
|
|
4
5
|
}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { AbstractControl, ValidationErrors } from '@angular/forms';
|
|
1
|
+
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
|
|
2
|
+
import { SkyUrlValidationOptions } from '../url-validation/url-validation-options';
|
|
2
3
|
export declare class SkyValidators {
|
|
3
4
|
/**
|
|
4
5
|
* Validates email addresses in reactive forms. Add this validator directly to the form control
|
|
5
6
|
* model in the component class. If users enter values that are not valid email addresses, the
|
|
6
7
|
* validator throws an error. Since this is a sync validator, it returns a set of validation
|
|
7
|
-
* errors or `
|
|
8
|
-
* @param control
|
|
8
|
+
* errors or `null` immediately when users enter values.
|
|
9
9
|
*/
|
|
10
10
|
static email(control: AbstractControl): ValidationErrors | null;
|
|
11
11
|
/**
|
|
12
12
|
* Validates URLs in reactive forms. Add this validator directly to the form control model in
|
|
13
13
|
* the component class. If users enter values that are not valid URLs, the validator throws an
|
|
14
|
-
* error. Since this is a sync validator, it returns a set of validation errors or `
|
|
14
|
+
* error. Since this is a sync validator, it returns a set of validation errors or `null`
|
|
15
15
|
* immediately when users enter values.
|
|
16
|
-
* @param control
|
|
17
16
|
*/
|
|
18
|
-
static url(
|
|
17
|
+
static url(abstractControl: AbstractControl): ValidationErrors | null;
|
|
18
|
+
/**
|
|
19
|
+
* Validates URLs in reactive forms. Add this validator with ruleset parameters directly to
|
|
20
|
+
* the form control model in the component class. If users enter values that are not valid
|
|
21
|
+
* URLs, the validator throws an error. Since this is a sync validator, it returns a set of
|
|
22
|
+
* validation errors or `null` immediately when users enter values.
|
|
23
|
+
*/
|
|
24
|
+
static url(skyUrlValidationOptions: SkyUrlValidationOptions): ValidatorFn | null;
|
|
19
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyux/validation",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"author": "Blackbaud, Inc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"blackbaud",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"@angular/forms": "^13.3.2"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"tslib": "^2.3.1"
|
|
40
|
+
"tslib": "^2.3.1",
|
|
41
|
+
"validator": "13.7.0"
|
|
41
42
|
},
|
|
42
43
|
"module": "fesm2015/skyux-validation.mjs",
|
|
43
44
|
"es2020": "fesm2020/skyux-validation.mjs",
|