iflrandevu/assets/js/utils/validation.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

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
* ---------------------------------------------------------------------------- */
/**
* 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);
}
/**
* Validate the provided phone.
*
* @param {String} value
*
* @return {Boolean}
*/
function phone(value) {
const re = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im;
return re.test(value);
}
2021-12-18 20:55:01 +03:00
return {
email,
phone
2021-12-18 20:55:01 +03:00
};
})();