@nattyjs/validation-decorators 0.0.1-beta.32 → 0.0.1-beta.33
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/index.cjs +2 -54
- package/dist/index.d.ts +1 -17
- package/dist/index.mjs +2 -54
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -8,9 +8,6 @@ const ValidatorNames = {
|
|
|
8
8
|
alpha: "alpha",
|
|
9
9
|
alphaNumeric: "alphaNumeric",
|
|
10
10
|
ascii: "ascii",
|
|
11
|
-
custom: "custom",
|
|
12
|
-
compare: "compare",
|
|
13
|
-
compose: "compose",
|
|
14
11
|
contains: "contains",
|
|
15
12
|
creditCard: "creditCard",
|
|
16
13
|
cusip: "cusip",
|
|
@@ -219,9 +216,9 @@ class Linq {
|
|
|
219
216
|
}
|
|
220
217
|
|
|
221
218
|
class ValidatorValueChecker {
|
|
222
|
-
static pass(params, config
|
|
219
|
+
static pass(params, config) {
|
|
223
220
|
if (Linq.execute(config, params))
|
|
224
|
-
return
|
|
221
|
+
return RegexValidator.isNotBlank(params.value);
|
|
225
222
|
else
|
|
226
223
|
return false;
|
|
227
224
|
}
|
|
@@ -251,52 +248,6 @@ function alphaNumericValidator(configModel, control) {
|
|
|
251
248
|
return alphaValidation(configModel, control, [RegExRule.alphaNumeric, RegExRule.alphaNumericWithSpace], ValidatorNames.alphaNumeric);
|
|
252
249
|
}
|
|
253
250
|
|
|
254
|
-
function compareValidator(configModel, control) {
|
|
255
|
-
let config = getConfigObject(configModel);
|
|
256
|
-
if (ValidatorValueChecker.pass(control, config)) {
|
|
257
|
-
const compareControlValue = control.current[config.fieldName];
|
|
258
|
-
if (RegexValidator.isNotBlank(compareControlValue)) {
|
|
259
|
-
if (!(compareControlValue === control.value))
|
|
260
|
-
return ValidationMessage.toJson(ValidatorNames.compare, config, [control.value, compareControlValue]);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return ValidationMessage.null();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function composeValidator(configModel, control) {
|
|
267
|
-
let config = getConfigObject(configModel);
|
|
268
|
-
if (ValidatorValueChecker.pass(control, config, true)) {
|
|
269
|
-
if (config.validators) {
|
|
270
|
-
let result = void 0;
|
|
271
|
-
for (let validator of config.validators) {
|
|
272
|
-
result = validator.validator(control);
|
|
273
|
-
if (result)
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
if (result)
|
|
277
|
-
return config.messageKey || config.message ? ValidationMessage.toJson(config.messageKey || ValidatorNames.compose, config, [control.value]) : result;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return ValidationMessage.null();
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function customValidator(configModel, control) {
|
|
284
|
-
let config = getConfigObject(configModel);
|
|
285
|
-
if (ValidatorValueChecker.pass(control, config, true)) {
|
|
286
|
-
if (config.validators) {
|
|
287
|
-
let result = void 0;
|
|
288
|
-
for (let validator of config.validators) {
|
|
289
|
-
result = validator(control);
|
|
290
|
-
if (result)
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
if (result)
|
|
294
|
-
return config.messageKey || config.message ? ValidationMessage.toJson(config.messageKey || ValidatorNames.custom, config, [control.value]) : result;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return ValidationMessage.null();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
251
|
function containsValidator(configModel, control) {
|
|
301
252
|
let config = getConfigObject(configModel);
|
|
302
253
|
if (ValidatorValueChecker.pass(control, config)) {
|
|
@@ -1600,9 +1551,6 @@ const ControlValidators = {
|
|
|
1600
1551
|
alpha: alphaValidator,
|
|
1601
1552
|
alphaNumeric: alphaNumericValidator,
|
|
1602
1553
|
ascii: asciiValidator,
|
|
1603
|
-
compare: compareValidator,
|
|
1604
|
-
compose: composeValidator,
|
|
1605
|
-
custom: customValidator,
|
|
1606
1554
|
contains: containsValidator,
|
|
1607
1555
|
creditCard: creditCardValidator,
|
|
1608
1556
|
cusip: cusipValidator,
|
package/dist/index.d.ts
CHANGED
|
@@ -384,19 +384,6 @@ declare function alphaValidator(configModel: AlphaConfig, params: ValidatorParam
|
|
|
384
384
|
|
|
385
385
|
declare function alphaNumericValidator(configModel: AlphaConfig, control: ValidatorParams): ValidatorFn;
|
|
386
386
|
|
|
387
|
-
interface CompareConfig extends FieldConfig {
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
declare function compareValidator(configModel: CompareConfig, control: ValidatorParams): ValidatorFn;
|
|
391
|
-
|
|
392
|
-
interface ComposeConfig extends BaseValidatorConfig {
|
|
393
|
-
validators: ValidatorFn[];
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
declare function composeValidator(configModel: ComposeConfig, control: ValidatorParams): ValidatorFn;
|
|
397
|
-
|
|
398
|
-
declare function customValidator(configModel: ComposeConfig, control: ValidatorParams): ValidatorFn;
|
|
399
|
-
|
|
400
387
|
declare function containsValidator(configModel: DefaultConfig, control: ValidatorParams): ValidatorFn;
|
|
401
388
|
|
|
402
389
|
declare function creditCardValidator(configModel: CreditCardConfig, control: ValidatorParams): ValidatorFn;
|
|
@@ -509,9 +496,6 @@ declare const ControlValidators: {
|
|
|
509
496
|
alpha: typeof alphaValidator;
|
|
510
497
|
alphaNumeric: typeof alphaNumericValidator;
|
|
511
498
|
ascii: typeof asciiValidator;
|
|
512
|
-
compare: typeof compareValidator;
|
|
513
|
-
compose: typeof composeValidator;
|
|
514
|
-
custom: typeof customValidator;
|
|
515
499
|
contains: typeof containsValidator;
|
|
516
500
|
creditCard: typeof creditCardValidator;
|
|
517
501
|
cusip: typeof cusipValidator;
|
|
@@ -595,4 +579,4 @@ declare const validationForms: {
|
|
|
595
579
|
configure(config: FormConfig): void;
|
|
596
580
|
};
|
|
597
581
|
|
|
598
|
-
export { AlphaConfig, ArrayConfig, BaseValidatorConfig,
|
|
582
|
+
export { AlphaConfig, ArrayConfig, BaseValidatorConfig, ContainsConfig, ControlValidators, CreditCardConfig, DateConfig, DefaultConfig, DifferentConfig, DigitConfig, EmailConfig, ExtensionConfig, FactorConfig, FieldConfig, FileConfig, FormConfig, HexColorConfig, IBANConfig, IpConfig, MaskConfig, MaxDateConfig, MaxTimeConfig, MessageConfig, MinDateConfig, MinTimeConfig, NumberConfig, NumericConfig, NumericValueType, PasswordConfig, PatternConfig, RangeConfig, RelationalOperatorConfig, RequiredConfig, StringComparisonConfig, StringValueConfig, TimeConfig, TimeRelationConfig, UrlConfig, ValidatorFn, allOf as decoratorAllOfValidation, alphaNumeric as decoratorAlphaNumericValidation, alpha as decoratorAlphaValidation, ascii as decoratorAsciiValidation, blacklist as decoratorBlacklistSanitizer, contains as decoratorContainsValidation, creditCard as decoratorCreditCardValidation, cusip as decoratorCusipValidation, dataUri as decoratorDataUriValidation, date as decoratorDateValidation, different as decoratorDifferentValdiation, digit as decoratorDigitValidation, email as decoratorEmailValidation, endsWith as decoratorEndsWithValidation, escape as decoratorEscapeSanitizer, even as decoratorEvenValidation, extension as decoratorExtensionValidation, factor as decoratorFactorValidation, greaterThanEqualTo as decoratorGreaterThanEqualToValidation, greaterThan as decoratorGreaterThanValidation, hexColor as decoratorHexColorValidation, ip as decoratorIpValidation, json as decoratorJsonValidation, latLong as decoratorLatLongValidation, latitude as decoratorLatitudeValdiation, leapYear as decoratorLeapYearValidation, lessThanEqualTo as decoratorLessThanEqualToValidation, lessThan as decoratorLessThanValidation, longitude as decoratorLongitudeValidation, lowerCase as decoratorLowercaseValidation, ltrim as decoratorLtrimSanitizer, mac as decoratorMacValidation, maxDate as decoratorMaxDateValidation, maxLength as decoratorMaxLengthValidation, maxNumber as decoratorMaxNumberValidation, maxTime as decoratorMaxTimeValidation, minDate as decoratorMinDateValidation, minLength as decoratorMinLengthValidation, minNumber as decoratorMinNumberValidation, minTime as decoratorMinTimeValidation, noneOf as decoratorNoneOfValidation, notEmpty as decoratorNotEmptyValidation, numeric as decoratorNumericValidation, odd as decoratorOddValidation, oneOf as decoratorOneOfValidation, password as decoratorPasswordValdiation, pattern as decoratorPatternValidation, port as decoratorPortValidation, prefix as decoratorPrefixSanitizer, primeNumber as decoratorPrimeNumberValidation, range as decoratorRangeValidation, decoratorRegistrationCaller, requiredTrue as decoratorRequiredTrueValidation, required as decoratorRequiredValidation, rtrim as decoratorRtrimSanitizer, sanitize as decoratorSanitizeSanitizer, startsWith as decoratorStartsWithValidation, stripLow as decoratorStripLowSanitizer, suffix as decoratorSuffixSanitizer, toBoolean as decoratorToBooleanSanitizer, toDate as decoratorToDateSanitizer, toInt as decoratorToIntSanitizer, toString as decoratorToStringSanitizer, trim as decoratorTrimSanitizer, upperCase as decoratorUpperCaseValidation, url as decoratorUrlValidation, whitelist as decoratorWhitelistSanitizer, prop, validationForms };
|
package/dist/index.mjs
CHANGED
|
@@ -4,9 +4,6 @@ const ValidatorNames = {
|
|
|
4
4
|
alpha: "alpha",
|
|
5
5
|
alphaNumeric: "alphaNumeric",
|
|
6
6
|
ascii: "ascii",
|
|
7
|
-
custom: "custom",
|
|
8
|
-
compare: "compare",
|
|
9
|
-
compose: "compose",
|
|
10
7
|
contains: "contains",
|
|
11
8
|
creditCard: "creditCard",
|
|
12
9
|
cusip: "cusip",
|
|
@@ -215,9 +212,9 @@ class Linq {
|
|
|
215
212
|
}
|
|
216
213
|
|
|
217
214
|
class ValidatorValueChecker {
|
|
218
|
-
static pass(params, config
|
|
215
|
+
static pass(params, config) {
|
|
219
216
|
if (Linq.execute(config, params))
|
|
220
|
-
return
|
|
217
|
+
return RegexValidator.isNotBlank(params.value);
|
|
221
218
|
else
|
|
222
219
|
return false;
|
|
223
220
|
}
|
|
@@ -247,52 +244,6 @@ function alphaNumericValidator(configModel, control) {
|
|
|
247
244
|
return alphaValidation(configModel, control, [RegExRule.alphaNumeric, RegExRule.alphaNumericWithSpace], ValidatorNames.alphaNumeric);
|
|
248
245
|
}
|
|
249
246
|
|
|
250
|
-
function compareValidator(configModel, control) {
|
|
251
|
-
let config = getConfigObject(configModel);
|
|
252
|
-
if (ValidatorValueChecker.pass(control, config)) {
|
|
253
|
-
const compareControlValue = control.current[config.fieldName];
|
|
254
|
-
if (RegexValidator.isNotBlank(compareControlValue)) {
|
|
255
|
-
if (!(compareControlValue === control.value))
|
|
256
|
-
return ValidationMessage.toJson(ValidatorNames.compare, config, [control.value, compareControlValue]);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return ValidationMessage.null();
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function composeValidator(configModel, control) {
|
|
263
|
-
let config = getConfigObject(configModel);
|
|
264
|
-
if (ValidatorValueChecker.pass(control, config, true)) {
|
|
265
|
-
if (config.validators) {
|
|
266
|
-
let result = void 0;
|
|
267
|
-
for (let validator of config.validators) {
|
|
268
|
-
result = validator.validator(control);
|
|
269
|
-
if (result)
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
if (result)
|
|
273
|
-
return config.messageKey || config.message ? ValidationMessage.toJson(config.messageKey || ValidatorNames.compose, config, [control.value]) : result;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return ValidationMessage.null();
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function customValidator(configModel, control) {
|
|
280
|
-
let config = getConfigObject(configModel);
|
|
281
|
-
if (ValidatorValueChecker.pass(control, config, true)) {
|
|
282
|
-
if (config.validators) {
|
|
283
|
-
let result = void 0;
|
|
284
|
-
for (let validator of config.validators) {
|
|
285
|
-
result = validator(control);
|
|
286
|
-
if (result)
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
if (result)
|
|
290
|
-
return config.messageKey || config.message ? ValidationMessage.toJson(config.messageKey || ValidatorNames.custom, config, [control.value]) : result;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return ValidationMessage.null();
|
|
294
|
-
}
|
|
295
|
-
|
|
296
247
|
function containsValidator(configModel, control) {
|
|
297
248
|
let config = getConfigObject(configModel);
|
|
298
249
|
if (ValidatorValueChecker.pass(control, config)) {
|
|
@@ -1596,9 +1547,6 @@ const ControlValidators = {
|
|
|
1596
1547
|
alpha: alphaValidator,
|
|
1597
1548
|
alphaNumeric: alphaNumericValidator,
|
|
1598
1549
|
ascii: asciiValidator,
|
|
1599
|
-
compare: compareValidator,
|
|
1600
|
-
compose: composeValidator,
|
|
1601
|
-
custom: customValidator,
|
|
1602
1550
|
contains: containsValidator,
|
|
1603
1551
|
creditCard: creditCardValidator,
|
|
1604
1552
|
cusip: cusipValidator,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nattyjs/validation-decorators",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.33",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"unbuild": "^0.7.4",
|
|
18
18
|
"@types/node": "20.3.1",
|
|
19
|
-
"@nattyjs/types": "0.0.1-beta.
|
|
19
|
+
"@nattyjs/types": "0.0.1-beta.33"
|
|
20
20
|
}
|
|
21
21
|
}
|