@verdocs/js-sdk 2.0.16 → 2.0.17
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/Templates/Validators.d.ts +2 -2
- package/Templates/Validators.js +5 -4
- package/Utils/Locales.d.ts +0 -1
- package/Utils/Locales.js +4 -4
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ export interface IValidator {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const getValidators: (endpoint: VerdocsEndpoint) => Promise<IValidator[]>;
|
|
17
17
|
export declare const getValidator: (endpoint: VerdocsEndpoint, validatorName: string) => Promise<IValidator>;
|
|
18
|
-
export declare const isValidEmail: (
|
|
19
|
-
export declare const isValidPhone: (
|
|
18
|
+
export declare const isValidEmail: (email: string | undefined) => boolean;
|
|
19
|
+
export declare const isValidPhone: (phone: string | undefined) => boolean;
|
|
20
20
|
export declare const isValidRoleName: (value: string, roles: IRole[]) => boolean;
|
|
21
21
|
export declare const isValidTag: (value: string, tags: ITag[]) => boolean;
|
package/Templates/Validators.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { simpleE164Validator } from '../Utils/Locales';
|
|
2
1
|
/**
|
|
3
2
|
* Get all defined validators
|
|
4
3
|
*
|
|
@@ -18,9 +17,11 @@ export var getValidator = function (endpoint, validatorName) {
|
|
|
18
17
|
.get("/validators/".concat(validatorName))
|
|
19
18
|
.then(function (r) { return r.data; });
|
|
20
19
|
};
|
|
21
|
-
var
|
|
22
|
-
export var isValidEmail = function (
|
|
23
|
-
|
|
20
|
+
var EMAIL_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,}))$/;
|
|
21
|
+
export var isValidEmail = function (email) { return !!email && EMAIL_REGEX.test(email); };
|
|
22
|
+
// @see https://www.regextester.com/1978
|
|
23
|
+
var PHONE_REGEX = /((?:\+|00)[17](?: |\-)?|(?:\+|00)[1-9]\d{0,2}(?: |\-)?|(?:\+|00)1\-\d{3}(?: |\-)?)?(0\d|\([0-9]{3}\)|[1-9]{0,3})(?:((?: |\-)[0-9]{2}){4}|((?:[0-9]{2}){4})|((?: |\-)[0-9]{3}(?: |\-)[0-9]{4})|([0-9]{7}))/;
|
|
24
|
+
export var isValidPhone = function (phone) { return !!phone && PHONE_REGEX.test(phone); };
|
|
24
25
|
export var isValidRoleName = function (value, roles) { return roles.findIndex(function (role) { return role.name === value; }) !== -1; };
|
|
25
26
|
var TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
|
|
26
27
|
export var isValidTag = function (value, tags) { return TagRegEx.test(value) || tags.findIndex(function (tag) { return tag.name === value; }) !== -1; };
|
package/Utils/Locales.d.ts
CHANGED
|
@@ -15,4 +15,3 @@ export declare function isAmericanSamoa(code: string): boolean;
|
|
|
15
15
|
export declare function isDominicanRepublic(code: string): boolean;
|
|
16
16
|
export declare function isPuertoRico(code: string): boolean;
|
|
17
17
|
export declare function getMatchingCountry(code: string, substrings: number): number;
|
|
18
|
-
export declare function simpleE164Validator(code: string): boolean;
|
package/Utils/Locales.js
CHANGED
|
@@ -1352,7 +1352,7 @@ export function getMatchingCountry(code, substrings) {
|
|
|
1352
1352
|
var toMatch = code.substring(0, substrings);
|
|
1353
1353
|
return Countries.filter(function (c) { return c.code === toMatch; }).length;
|
|
1354
1354
|
}
|
|
1355
|
-
|
|
1356
|
-
export function simpleE164Validator(code) {
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1355
|
+
// const e164Regex = new RegExp(/\+[1-9]\d{6,14}/g);
|
|
1356
|
+
// export function simpleE164Validator(code: string) {
|
|
1357
|
+
// return (code !== null && code.length < 16 && code.length > 6 && e164Regex.test(code)) || code === '' || code === null;
|
|
1358
|
+
// }
|