UNPKG

sweetalert2

Version:

A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert

24 lines (23 loc) 822 B
export default { /** * @param {string} string * @param {string} [validationMessage] * @returns {Promise<string | void>} */ email: (string, validationMessage) => { return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address') }, /** * @param {string} string * @param {string} [validationMessage] * @returns {Promise<string | void>} */ url: (string, validationMessage) => { // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013 return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid URL') }, }