@breadstone/mosaik-elements-angular 0.0.188 → 0.0.189
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/CHANGELOG.md
CHANGED
|
@@ -61155,22 +61155,40 @@ class Validators {
|
|
|
61155
61155
|
}
|
|
61156
61156
|
|
|
61157
61157
|
// #region Imports
|
|
61158
|
+
// #endregion
|
|
61159
|
+
/**
|
|
61160
|
+
* Retrieves the option value, evaluating it if it's a function.
|
|
61161
|
+
*
|
|
61162
|
+
* @private
|
|
61163
|
+
* @param opt The option value or function to evaluate.
|
|
61164
|
+
* @param ctx The field context to pass if `opt` is a function.
|
|
61165
|
+
* @returns The resolved option value.
|
|
61166
|
+
*/
|
|
61167
|
+
function getOption(opt, ctx) {
|
|
61168
|
+
return opt instanceof Function ? opt(ctx) : opt;
|
|
61169
|
+
}
|
|
61158
61170
|
/**
|
|
61159
61171
|
* Validator to check if control value is only numeric.
|
|
61160
61172
|
*
|
|
61161
61173
|
* @param path The schema path to validate.
|
|
61162
61174
|
* @public
|
|
61163
61175
|
*/
|
|
61164
|
-
function numeric(path) {
|
|
61176
|
+
function numeric(path, config) {
|
|
61165
61177
|
validate(path, (ctx) => {
|
|
61166
61178
|
const value = ctx.value();
|
|
61167
61179
|
if (value === null || value === undefined || !Number.isNaN(+value)) {
|
|
61168
61180
|
return null;
|
|
61169
61181
|
}
|
|
61170
|
-
|
|
61171
|
-
|
|
61172
|
-
|
|
61173
|
-
|
|
61182
|
+
if (config?.error) {
|
|
61183
|
+
return getOption(config.error, ctx);
|
|
61184
|
+
}
|
|
61185
|
+
else {
|
|
61186
|
+
return {
|
|
61187
|
+
kind: 'numeric',
|
|
61188
|
+
actualValue: value,
|
|
61189
|
+
message: typeof config?.message === 'function' ? config.message(ctx) : config?.message,
|
|
61190
|
+
};
|
|
61191
|
+
}
|
|
61174
61192
|
});
|
|
61175
61193
|
}
|
|
61176
61194
|
/**
|
|
@@ -61180,18 +61198,24 @@ function numeric(path) {
|
|
|
61180
61198
|
* @param other A value or getter function returning the other value.
|
|
61181
61199
|
* @public
|
|
61182
61200
|
*/
|
|
61183
|
-
function equalsTo(path, other) {
|
|
61201
|
+
function equalsTo(path, other, config) {
|
|
61184
61202
|
validate(path, (ctx) => {
|
|
61185
61203
|
const value = ctx.value();
|
|
61186
61204
|
const otherValue = typeof other === 'function' ? other() : other;
|
|
61187
61205
|
if (value === otherValue) {
|
|
61188
61206
|
return null;
|
|
61189
61207
|
}
|
|
61190
|
-
|
|
61191
|
-
|
|
61192
|
-
|
|
61193
|
-
|
|
61194
|
-
|
|
61208
|
+
if (config?.error) {
|
|
61209
|
+
return getOption(config.error, ctx);
|
|
61210
|
+
}
|
|
61211
|
+
else {
|
|
61212
|
+
return {
|
|
61213
|
+
kind: 'equalsTo',
|
|
61214
|
+
actualValue: value,
|
|
61215
|
+
other: otherValue,
|
|
61216
|
+
message: typeof config?.message === 'function' ? config.message(ctx) : config?.message,
|
|
61217
|
+
};
|
|
61218
|
+
}
|
|
61195
61219
|
});
|
|
61196
61220
|
}
|
|
61197
61221
|
/**
|
|
@@ -61200,16 +61224,22 @@ function equalsTo(path, other) {
|
|
|
61200
61224
|
* @param path The schema path to validate.
|
|
61201
61225
|
* @public
|
|
61202
61226
|
*/
|
|
61203
|
-
function blank(path) {
|
|
61227
|
+
function blank(path, config) {
|
|
61204
61228
|
validate(path, (ctx) => {
|
|
61205
61229
|
const value = ctx.value();
|
|
61206
|
-
if (typeof value === 'string' && (/\s/).test(value)) {
|
|
61230
|
+
if (!(typeof value === 'string' && (/\s/).test(value))) {
|
|
61231
|
+
return null;
|
|
61232
|
+
}
|
|
61233
|
+
if (config?.error) {
|
|
61234
|
+
return getOption(config.error, ctx);
|
|
61235
|
+
}
|
|
61236
|
+
else {
|
|
61207
61237
|
return {
|
|
61208
61238
|
kind: 'blank',
|
|
61209
|
-
actualValue: value
|
|
61239
|
+
actualValue: value,
|
|
61240
|
+
message: typeof config?.message === 'function' ? config.message(ctx) : config?.message,
|
|
61210
61241
|
};
|
|
61211
61242
|
}
|
|
61212
|
-
return null;
|
|
61213
61243
|
});
|
|
61214
61244
|
}
|
|
61215
61245
|
/**
|
|
@@ -61219,7 +61249,7 @@ function blank(path) {
|
|
|
61219
61249
|
* @param domains The list of allowed domains.
|
|
61220
61250
|
* @public
|
|
61221
61251
|
*/
|
|
61222
|
-
function emailEndsWithDomain(path, domains) {
|
|
61252
|
+
function emailEndsWithDomain(path, domains, config) {
|
|
61223
61253
|
const pattern = `^\\w+([-.']\\w+)*@(?:(${domains.join('|')}))$`;
|
|
61224
61254
|
const regex = new RegExp(pattern);
|
|
61225
61255
|
validate(path, (ctx) => {
|
|
@@ -61230,11 +61260,16 @@ function emailEndsWithDomain(path, domains) {
|
|
|
61230
61260
|
if (typeof value === 'string' && regex.test(value)) {
|
|
61231
61261
|
return null;
|
|
61232
61262
|
}
|
|
61233
|
-
|
|
61234
|
-
|
|
61235
|
-
|
|
61236
|
-
|
|
61237
|
-
|
|
61263
|
+
if (config?.error) {
|
|
61264
|
+
return getOption(config.error, ctx);
|
|
61265
|
+
}
|
|
61266
|
+
else {
|
|
61267
|
+
return {
|
|
61268
|
+
kind: 'emailEndsWithDomain',
|
|
61269
|
+
requiredDomains: domains,
|
|
61270
|
+
actualValue: value
|
|
61271
|
+
};
|
|
61272
|
+
}
|
|
61238
61273
|
});
|
|
61239
61274
|
}
|
|
61240
61275
|
/**
|
|
@@ -61243,7 +61278,7 @@ function emailEndsWithDomain(path, domains) {
|
|
|
61243
61278
|
* @param path The schema path to validate.
|
|
61244
61279
|
* @public
|
|
61245
61280
|
*/
|
|
61246
|
-
function phoneNumber(path) {
|
|
61281
|
+
function phoneNumber(path, config) {
|
|
61247
61282
|
const pattern = '^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\.\\/0-9]*$';
|
|
61248
61283
|
const regex = new RegExp(pattern);
|
|
61249
61284
|
validate(path, (ctx) => {
|
|
@@ -61254,10 +61289,15 @@ function phoneNumber(path) {
|
|
|
61254
61289
|
if (typeof value === 'string' && regex.test(value)) {
|
|
61255
61290
|
return null;
|
|
61256
61291
|
}
|
|
61257
|
-
|
|
61258
|
-
|
|
61259
|
-
|
|
61260
|
-
|
|
61292
|
+
if (config?.error) {
|
|
61293
|
+
return getOption(config.error, ctx);
|
|
61294
|
+
}
|
|
61295
|
+
else {
|
|
61296
|
+
return {
|
|
61297
|
+
kind: 'phoneNumber',
|
|
61298
|
+
actualValue: value
|
|
61299
|
+
};
|
|
61300
|
+
}
|
|
61261
61301
|
});
|
|
61262
61302
|
}
|
|
61263
61303
|
|