@bizy/core 19.13.7 → 19.14.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/fesm2022/bizy-core.mjs
CHANGED
|
@@ -26,6 +26,7 @@ import Dashboard from '@uppy/dashboard';
|
|
|
26
26
|
import XHRUpload from '@uppy/xhr-upload';
|
|
27
27
|
import * as i1$1 from '@angular/router';
|
|
28
28
|
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
|
|
29
|
+
import validator from 'validator';
|
|
29
30
|
import { Clipboard } from '@angular/cdk/clipboard';
|
|
30
31
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
|
31
32
|
import * as i3 from '@angular/cdk/portal';
|
|
@@ -2930,52 +2931,249 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
|
|
|
2930
2931
|
}] }] });
|
|
2931
2932
|
|
|
2932
2933
|
class BizyValidatorService {
|
|
2933
|
-
isEmail(
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
const
|
|
2939
|
-
const
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2934
|
+
isEmail = (value) => validator.isEmail(value);
|
|
2935
|
+
dateIsAfter = (data) => {
|
|
2936
|
+
if (!data || !data.date || !data.comparisonDate) {
|
|
2937
|
+
return false;
|
|
2938
|
+
}
|
|
2939
|
+
const date = new Date(data.date);
|
|
2940
|
+
const comparisonDate = new Date(data.comparisonDate);
|
|
2941
|
+
return validator.isAfter(date.toString(), comparisonDate.toString());
|
|
2942
|
+
};
|
|
2943
|
+
dateIsBefore = (data) => {
|
|
2944
|
+
if (!data || !data.date || !data.comparisonDate) {
|
|
2945
|
+
return false;
|
|
2946
|
+
}
|
|
2947
|
+
const date = new Date(data.date);
|
|
2948
|
+
const comparisonDate = new Date(data.comparisonDate);
|
|
2949
|
+
return validator.isBefore(date.toString(), comparisonDate.toString());
|
|
2950
|
+
};
|
|
2951
|
+
isAlpha = (value) => validator.isAlpha(value);
|
|
2952
|
+
isAlphanumeric = (value) => validator.isAlphanumeric(value);
|
|
2953
|
+
isNumeric = (value) => validator.isNumeric(value);
|
|
2947
2954
|
isNumber(number) {
|
|
2948
|
-
const regex =
|
|
2949
|
-
return regex.test(String(number).toLowerCase());
|
|
2950
|
-
}
|
|
2951
|
-
isPhoneNumber(number) {
|
|
2952
|
-
const regex = /^\+{0,1}[0-9#*]+$/;
|
|
2955
|
+
const regex = /^-?\d+(\.\d+)?$/;
|
|
2953
2956
|
return regex.test(String(number).toLowerCase());
|
|
2954
2957
|
}
|
|
2955
2958
|
isString(string) {
|
|
2956
2959
|
return typeof string === 'string' || string instanceof String;
|
|
2957
2960
|
}
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2961
|
+
isInteger = (value) => validator.isInt(value);
|
|
2962
|
+
isBoolean = (value) => validator.isBoolean(value);
|
|
2963
|
+
isCreditCard = (value) => validator.isCreditCard(value);
|
|
2964
|
+
isDataURI = (value) => validator.isDataURI(value);
|
|
2965
|
+
isURL = (value) => validator.isURL(value);
|
|
2966
|
+
isDate = (value) => validator.isDate(value);
|
|
2967
|
+
isJSON = (value) => validator.isJSON(value);
|
|
2968
|
+
isIP = (value, version) => validator.isIP(value, { version });
|
|
2969
|
+
isJWT = (value) => validator.isJWT(value);
|
|
2970
|
+
isLowercase = (value) => validator.isLowercase(value);
|
|
2971
|
+
isUppercase = (value) => validator.isUppercase(value);
|
|
2972
|
+
isMobilePhone = (data) => validator.isMobilePhone(data.value, data.locale);
|
|
2973
|
+
isCUIT(cuit) {
|
|
2974
|
+
const regex = /(^[0-9]{2}-[0-9]{8}-[0-9]$)/i;
|
|
2975
|
+
const isCUIT = regex.test(String(cuit).toLowerCase());
|
|
2976
|
+
if (!isCUIT) {
|
|
2977
|
+
return false;
|
|
2978
|
+
}
|
|
2979
|
+
cuit = String(cuit).replace(/[-_]/g, '');
|
|
2980
|
+
if (cuit.length == 11) {
|
|
2981
|
+
const mult = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
|
|
2982
|
+
let total = 0;
|
|
2983
|
+
for (let i = 0; i < mult.length; i++) {
|
|
2984
|
+
total += parseInt(cuit[i]) * mult[i];
|
|
2985
|
+
}
|
|
2986
|
+
const mod = total % 11;
|
|
2987
|
+
const digit = mod === 0 ? 0 : mod === 1 ? 9 : 11 - mod;
|
|
2988
|
+
return digit === parseInt(cuit[10]);
|
|
2963
2989
|
}
|
|
2964
2990
|
return false;
|
|
2965
2991
|
}
|
|
2992
|
+
isDNI(dni) {
|
|
2993
|
+
const regex = /(^[1-9]{1}[0-9]{7}$)/i;
|
|
2994
|
+
return regex.test(String(dni).toLowerCase());
|
|
2995
|
+
}
|
|
2996
|
+
isCBU(cbu) {
|
|
2997
|
+
const _isLengthOk = (cbu) => {
|
|
2998
|
+
return cbu.length === 22;
|
|
2999
|
+
};
|
|
3000
|
+
const _isValidAccount = (account) => {
|
|
3001
|
+
if (account.length !== 14) {
|
|
3002
|
+
return false;
|
|
3003
|
+
}
|
|
3004
|
+
const sum = Number(account[0]) * 3 +
|
|
3005
|
+
Number(account[1]) * 9 +
|
|
3006
|
+
Number(account[2]) * 7 +
|
|
3007
|
+
Number(account[3]) * 1 +
|
|
3008
|
+
Number(account[4]) * 3 +
|
|
3009
|
+
Number(account[5]) * 9 +
|
|
3010
|
+
Number(account[6]) * 7 +
|
|
3011
|
+
Number(account[7]) * 1 +
|
|
3012
|
+
Number(account[8]) * 3 +
|
|
3013
|
+
Number(account[9]) * 9 +
|
|
3014
|
+
Number(account[10]) * 7 +
|
|
3015
|
+
Number(account[11]) * 1 +
|
|
3016
|
+
Number(account[12]) * 3;
|
|
3017
|
+
const diff = (10 - (sum % 10)) % 10; // The result of this should be only 1 digit
|
|
3018
|
+
const checksum = Number(account[13]);
|
|
3019
|
+
return diff === checksum;
|
|
3020
|
+
};
|
|
3021
|
+
const _isValidBankCode = (code) => {
|
|
3022
|
+
if (code.length !== 8) {
|
|
3023
|
+
return false;
|
|
3024
|
+
}
|
|
3025
|
+
const bank = code.substring(0, 3);
|
|
3026
|
+
const checksumOne = code[3];
|
|
3027
|
+
const branch = code.substring(4, 4 + 3);
|
|
3028
|
+
const checksumTwo = code[7];
|
|
3029
|
+
const sum = (Number(bank[0]) * 7) +
|
|
3030
|
+
(Number(bank[1]) * 1) +
|
|
3031
|
+
(Number(bank[2]) * 3) +
|
|
3032
|
+
(Number(checksumOne) * 9) +
|
|
3033
|
+
(Number(branch[0]) * 7) +
|
|
3034
|
+
(Number(branch[1]) * 1) +
|
|
3035
|
+
(Number(branch[2]) * 3);
|
|
3036
|
+
const diff = (10 - (sum % 10)) % 10; // The result of this should be only 1 digit
|
|
3037
|
+
return diff === Number(checksumTwo);
|
|
3038
|
+
};
|
|
3039
|
+
const bankCode = cbu.substring(0, 8);
|
|
3040
|
+
const accountCode = cbu.substring(8, 8 + 14);
|
|
3041
|
+
return (_isLengthOk(cbu) &&
|
|
3042
|
+
_isValidBankCode(bankCode) &&
|
|
3043
|
+
_isValidAccount(accountCode));
|
|
3044
|
+
}
|
|
2966
3045
|
emailValidator() {
|
|
2967
3046
|
return (control) => {
|
|
2968
|
-
return !control.value || (control.value && this.isEmail(control.value))
|
|
3047
|
+
return !control.value || (control.value && this.isEmail(control.value))
|
|
3048
|
+
? null
|
|
3049
|
+
: { anuraEmail: true };
|
|
2969
3050
|
};
|
|
2970
3051
|
}
|
|
2971
|
-
|
|
3052
|
+
mobilePhoneValidator(locale) {
|
|
2972
3053
|
return (control) => {
|
|
2973
|
-
return !control.value ||
|
|
3054
|
+
return !control.value || !locale ||
|
|
3055
|
+
(control.value && locale && this.isMobilePhone({ value: control.value, locale }))
|
|
3056
|
+
? null
|
|
3057
|
+
: { anuraMobilePhone: true };
|
|
2974
3058
|
};
|
|
2975
3059
|
}
|
|
2976
3060
|
numberValidator() {
|
|
2977
3061
|
return (control) => {
|
|
2978
|
-
return !control.value || (control.value && this.isNumber(control.value))
|
|
3062
|
+
return !control.value || (control.value && this.isNumber(control.value))
|
|
3063
|
+
? null
|
|
3064
|
+
: { anuraNumber: true };
|
|
3065
|
+
};
|
|
3066
|
+
}
|
|
3067
|
+
numericValidator() {
|
|
3068
|
+
return (control) => {
|
|
3069
|
+
return !control.value || (control.value && this.isNumeric(control.value))
|
|
3070
|
+
? null
|
|
3071
|
+
: { anuraNumeric: true };
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
dateIsAfterValidator(comparisonDate) {
|
|
3075
|
+
return (control) => {
|
|
3076
|
+
return !control.value || !comparisonDate || (control.value && comparisonDate && !this.dateIsAfter({ date: control.value, comparisonDate }))
|
|
3077
|
+
? null
|
|
3078
|
+
: { anuraDateIsAfter: true };
|
|
3079
|
+
};
|
|
3080
|
+
}
|
|
3081
|
+
dateIsBeforeValidator(comparisonDate) {
|
|
3082
|
+
return (control) => {
|
|
3083
|
+
return !control.value || !comparisonDate || (control.value && comparisonDate && !this.dateIsBefore({ date: control.value, comparisonDate }))
|
|
3084
|
+
? null
|
|
3085
|
+
: { anuraDateIsBefore: true };
|
|
3086
|
+
};
|
|
3087
|
+
}
|
|
3088
|
+
alphaValidator() {
|
|
3089
|
+
return (control) => {
|
|
3090
|
+
return !control.value || (control.value && this.isAlpha(control.value))
|
|
3091
|
+
? null
|
|
3092
|
+
: { anuraAlpha: true };
|
|
3093
|
+
};
|
|
3094
|
+
}
|
|
3095
|
+
alphanumericValidator() {
|
|
3096
|
+
return (control) => {
|
|
3097
|
+
return !control.value || (control.value && this.isAlphanumeric(control.value))
|
|
3098
|
+
? null
|
|
3099
|
+
: { anuraAlphanumeric: true };
|
|
3100
|
+
};
|
|
3101
|
+
}
|
|
3102
|
+
integerValidator() {
|
|
3103
|
+
return (control) => {
|
|
3104
|
+
return !control.value || (control.value && this.isInteger(control.value))
|
|
3105
|
+
? null
|
|
3106
|
+
: { anuraInteger: true };
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
dataURIValidator() {
|
|
3110
|
+
return (control) => {
|
|
3111
|
+
return !control.value || (control.value && this.isDataURI(control.value))
|
|
3112
|
+
? null
|
|
3113
|
+
: { anuraDataURI: true };
|
|
3114
|
+
};
|
|
3115
|
+
}
|
|
3116
|
+
urlValidator() {
|
|
3117
|
+
return (control) => {
|
|
3118
|
+
return !control.value || (control.value && this.isURL(control.value))
|
|
3119
|
+
? null
|
|
3120
|
+
: { anuraURL: true };
|
|
3121
|
+
};
|
|
3122
|
+
}
|
|
3123
|
+
jsonValidator() {
|
|
3124
|
+
return (control) => {
|
|
3125
|
+
return !control.value || (control.value && this.isJSON(control.value))
|
|
3126
|
+
? null
|
|
3127
|
+
: { anuraJSON: true };
|
|
3128
|
+
};
|
|
3129
|
+
}
|
|
3130
|
+
jwtValidator() {
|
|
3131
|
+
return (control) => {
|
|
3132
|
+
return !control.value || (control.value && this.isJWT(control.value))
|
|
3133
|
+
? null
|
|
3134
|
+
: { anuraJWT: true };
|
|
3135
|
+
};
|
|
3136
|
+
}
|
|
3137
|
+
lowerCaseValidator() {
|
|
3138
|
+
return (control) => {
|
|
3139
|
+
return !control.value || (control.value && this.isLowercase(control.value))
|
|
3140
|
+
? null
|
|
3141
|
+
: { anuraLowerCase: true };
|
|
3142
|
+
};
|
|
3143
|
+
}
|
|
3144
|
+
upperCaseValidator() {
|
|
3145
|
+
return (control) => {
|
|
3146
|
+
return !control.value || (control.value && this.isUppercase(control.value))
|
|
3147
|
+
? null
|
|
3148
|
+
: { anuraUpperCase: true };
|
|
3149
|
+
};
|
|
3150
|
+
}
|
|
3151
|
+
cuitValidator() {
|
|
3152
|
+
return (control) => {
|
|
3153
|
+
return !control.value || (control.value && this.isCUIT(control.value))
|
|
3154
|
+
? null
|
|
3155
|
+
: { anuraCUIT: true };
|
|
3156
|
+
};
|
|
3157
|
+
}
|
|
3158
|
+
dniValidator() {
|
|
3159
|
+
return (control) => {
|
|
3160
|
+
return !control.value || (control.value && this.isDNI(control.value))
|
|
3161
|
+
? null
|
|
3162
|
+
: { anuraDNI: true };
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
cbuValidator() {
|
|
3166
|
+
return (control) => {
|
|
3167
|
+
return !control.value || (control.value && this.isCBU(control.value))
|
|
3168
|
+
? null
|
|
3169
|
+
: { anuraCBU: true };
|
|
3170
|
+
};
|
|
3171
|
+
}
|
|
3172
|
+
creditCardValidator() {
|
|
3173
|
+
return (control) => {
|
|
3174
|
+
return !control.value || (control.value && this.isCreditCard(control.value))
|
|
3175
|
+
? null
|
|
3176
|
+
: { anuraCreditCard: true };
|
|
2979
3177
|
};
|
|
2980
3178
|
}
|
|
2981
3179
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: BizyValidatorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|