2021-12-18 20:55:01 +03:00
|
|
|
/* ----------------------------------------------------------------------------
|
2022-01-18 15:05:42 +03:00
|
|
|
* Easy!Appointments - Online Appointment Scheduler
|
2021-12-18 20:55:01 +03:00
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
|
|
* @copyright Copyright (c) Alex Tselegidis
|
|
|
|
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link https://easyappointments.org
|
|
|
|
* @since v1.5.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
2022-01-14 11:26:44 +03:00
|
|
|
/**
|
|
|
|
* Validation utility.
|
|
|
|
*
|
|
|
|
* This module implements the functionality of validation.
|
|
|
|
*/
|
2021-12-18 20:55:01 +03:00
|
|
|
window.App.Utils.Validation = (function () {
|
|
|
|
/**
|
|
|
|
* Validate the provided email.
|
|
|
|
*
|
|
|
|
* @param {String} value
|
|
|
|
*
|
|
|
|
* @return {Boolean}
|
|
|
|
*/
|
|
|
|
function email(value) {
|
|
|
|
const re =
|
2022-01-11 18:25:14 +03:00
|
|
|
/^(([^<>()[\]\\.,;:\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,}))$/;
|
2021-12-18 20:55:01 +03:00
|
|
|
|
|
|
|
return re.test(value);
|
|
|
|
}
|
|
|
|
|
2022-01-24 17:48:20 +03:00
|
|
|
/**
|
|
|
|
* Validate the provided phone.
|
|
|
|
*
|
|
|
|
* @param {String} value
|
|
|
|
*
|
|
|
|
* @return {Boolean}
|
|
|
|
*/
|
|
|
|
function phone(value) {
|
2022-01-24 22:44:52 +03:00
|
|
|
const re = /^[+]?([0-9]*[\.\s\-\(\)]|[0-9]+){3,24}$/;
|
2022-01-24 17:48:20 +03:00
|
|
|
|
|
|
|
return re.test(value);
|
|
|
|
}
|
|
|
|
|
2021-12-18 20:55:01 +03:00
|
|
|
return {
|
2022-01-24 17:48:20 +03:00
|
|
|
email,
|
2023-12-22 13:35:41 +03:00
|
|
|
phone,
|
2021-12-18 20:55:01 +03:00
|
|
|
};
|
|
|
|
})();
|