@skyux/validation 5.9.6 → 5.11.2
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/bundles/skyux-validation.umd.js +75 -36
- package/documentation.json +266 -97
- package/esm2015/index.js +1 -0
- package/esm2015/index.js.map +1 -1
- package/esm2015/lib/modules/url-validation/url-validation-options.js +2 -0
- package/esm2015/lib/modules/url-validation/url-validation-options.js.map +1 -0
- package/esm2015/lib/modules/url-validation/url-validation.directive.js +23 -14
- package/esm2015/lib/modules/url-validation/url-validation.directive.js.map +1 -1
- package/esm2015/lib/modules/validation/validation.js +18 -2
- package/esm2015/lib/modules/validation/validation.js.map +1 -1
- package/esm2015/lib/modules/validators/validators.js +28 -18
- package/esm2015/lib/modules/validators/validators.js.map +1 -1
- package/fesm2015/skyux-validation.js +68 -33
- package/fesm2015/skyux-validation.js.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,8 +1,10 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@skyux/validation', ['exports', '@angular/core', '@angular/forms'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.skyux = global.skyux || {}, global.skyux.validation = {}), global.ng.core, global.ng.forms));
|
|
5
|
-
})(this, (function (exports, i0, forms) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('validator/es/lib/isURL')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@skyux/validation', ['exports', '@angular/core', '@angular/forms', 'validator/es/lib/isURL'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.skyux = global.skyux || {}, global.skyux.validation = {}), global.ng.core, global.ng.forms, global.isURL));
|
|
5
|
+
})(this, (function (exports, i0, forms, isURL) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
8
|
|
|
7
9
|
function _interopNamespace(e) {
|
|
8
10
|
if (e && e.__esModule) return e;
|
|
@@ -23,6 +25,7 @@
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
28
|
+
var isURL__default = /*#__PURE__*/_interopDefaultLegacy(isURL);
|
|
26
29
|
|
|
27
30
|
var SkyValidation = /** @class */ (function () {
|
|
28
31
|
function SkyValidation() {
|
|
@@ -34,9 +37,24 @@
|
|
|
34
37
|
var regex = /^(([^<>()[\]\\.,;:\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,}))$/;
|
|
35
38
|
return regex.test(emailAddress);
|
|
36
39
|
};
|
|
37
|
-
SkyValidation.isUrl = function (
|
|
40
|
+
SkyValidation.isUrl = function (value, options) {
|
|
41
|
+
if (typeof value !== 'string') {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
var url = value;
|
|
38
45
|
var regex = /^((http|https):\/\/)?([\w-]+\.)+[\w-]+/i;
|
|
39
|
-
|
|
46
|
+
if (options) {
|
|
47
|
+
switch (options.rulesetVersion) {
|
|
48
|
+
case 1:
|
|
49
|
+
return regex.test(url);
|
|
50
|
+
case 2:
|
|
51
|
+
// we are using the `validator` package's default options
|
|
52
|
+
return isURL__default["default"](url);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return regex.test(url);
|
|
57
|
+
}
|
|
40
58
|
};
|
|
41
59
|
return SkyValidation;
|
|
42
60
|
}());
|
|
@@ -115,34 +133,45 @@
|
|
|
115
133
|
*/
|
|
116
134
|
var SkyUrlValidationDirective = /** @class */ (function () {
|
|
117
135
|
function SkyUrlValidationDirective() {
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
137
|
+
this._validatorChange = function () { };
|
|
118
138
|
}
|
|
139
|
+
Object.defineProperty(SkyUrlValidationDirective.prototype, "skyUrlValidation", {
|
|
140
|
+
/**
|
|
141
|
+
* Specifies configuration options for the URL validation component.
|
|
142
|
+
*/
|
|
143
|
+
set: function (value) {
|
|
144
|
+
this._skyUrlValidationOptions = value;
|
|
145
|
+
this._validatorChange();
|
|
146
|
+
},
|
|
147
|
+
enumerable: false,
|
|
148
|
+
configurable: true
|
|
149
|
+
});
|
|
119
150
|
SkyUrlValidationDirective.prototype.validate = function (control) {
|
|
120
151
|
var value = control.value;
|
|
121
152
|
if (!value) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (!this.urlIsValid(value)) {
|
|
125
|
-
return {
|
|
126
|
-
skyUrl: {
|
|
127
|
-
invalid: control.value,
|
|
128
|
-
},
|
|
129
|
-
};
|
|
153
|
+
return null;
|
|
130
154
|
}
|
|
155
|
+
return SkyValidation.isUrl(value, this._skyUrlValidationOptions)
|
|
156
|
+
? null
|
|
157
|
+
: { skyUrl: { invalid: value } };
|
|
131
158
|
};
|
|
132
|
-
SkyUrlValidationDirective.prototype.
|
|
133
|
-
|
|
159
|
+
SkyUrlValidationDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
160
|
+
this._validatorChange = fn;
|
|
134
161
|
};
|
|
135
162
|
return SkyUrlValidationDirective;
|
|
136
163
|
}());
|
|
137
164
|
SkyUrlValidationDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyUrlValidationDirective, deps: [], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
138
|
-
SkyUrlValidationDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyUrlValidationDirective, selector: "[skyUrlValidation]", providers: [SKY_URL_VALIDATION_VALIDATOR], ngImport: i0__namespace });
|
|
165
|
+
SkyUrlValidationDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyUrlValidationDirective, selector: "[skyUrlValidation]", inputs: { skyUrlValidation: "skyUrlValidation" }, providers: [SKY_URL_VALIDATION_VALIDATOR], ngImport: i0__namespace });
|
|
139
166
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyUrlValidationDirective, decorators: [{
|
|
140
167
|
type: i0.Directive,
|
|
141
168
|
args: [{
|
|
142
169
|
selector: '[skyUrlValidation]',
|
|
143
170
|
providers: [SKY_URL_VALIDATION_VALIDATOR],
|
|
144
171
|
}]
|
|
145
|
-
}]
|
|
172
|
+
}], propDecorators: { skyUrlValidation: [{
|
|
173
|
+
type: i0.Input
|
|
174
|
+
}] } });
|
|
146
175
|
|
|
147
176
|
var SkyUrlValidationModule = /** @class */ (function () {
|
|
148
177
|
function SkyUrlValidationModule() {
|
|
@@ -171,33 +200,43 @@
|
|
|
171
200
|
* Validates email addresses in reactive forms. Add this validator directly to the form control
|
|
172
201
|
* model in the component class. If users enter values that are not valid email addresses, the
|
|
173
202
|
* validator throws an error. Since this is a sync validator, it returns a set of validation
|
|
174
|
-
* errors or `
|
|
175
|
-
* @param control
|
|
203
|
+
* errors or `null` immediately when users enter values.
|
|
176
204
|
*/
|
|
177
205
|
SkyValidators.email = function (control) {
|
|
178
206
|
var value = control.value;
|
|
179
207
|
if (!value) {
|
|
180
|
-
return
|
|
208
|
+
return null;
|
|
181
209
|
}
|
|
182
210
|
return SkyValidation.isEmail(value)
|
|
183
|
-
?
|
|
211
|
+
? null
|
|
184
212
|
: { skyEmail: { invalid: value } };
|
|
185
213
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
214
|
+
SkyValidators.url = function (value) {
|
|
215
|
+
var typeTester = value;
|
|
216
|
+
if (typeTester.rulesetVersion === undefined) {
|
|
217
|
+
// there are no SkyUrlValidationOptions passed in, so return ValidationErrors | null
|
|
218
|
+
var abstractControl = value;
|
|
219
|
+
var abstractControlValue = abstractControl.value;
|
|
220
|
+
if (!abstractControlValue) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
return SkyValidation.isUrl(abstractControlValue)
|
|
224
|
+
? null
|
|
225
|
+
: { skyUrl: { invalid: abstractControlValue } };
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
// there are SkyUrlValidationOptions passed in, so return ValidatorFn
|
|
229
|
+
var skyUrlValidationOptions_1 = value;
|
|
230
|
+
return function (abstractControl) {
|
|
231
|
+
var abstractControlValue = abstractControl.value;
|
|
232
|
+
if (!abstractControlValue) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
return SkyValidation.isUrl(abstractControl.value, skyUrlValidationOptions_1)
|
|
236
|
+
? null
|
|
237
|
+
: { skyUrl: { invalid: abstractControl.value } };
|
|
238
|
+
};
|
|
197
239
|
}
|
|
198
|
-
return SkyValidation.isUrl(value)
|
|
199
|
-
? undefined
|
|
200
|
-
: { skyUrl: { invalid: value } };
|
|
201
240
|
};
|
|
202
241
|
return SkyValidators;
|
|
203
242
|
}());
|