UNPKG

quasar

Version:

Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time

41 lines (33 loc) 1.72 kB
// file referenced from docs const hex = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/, hexa = /^#[0-9a-fA-F]{4}([0-9a-fA-F]{4})?$/, hexOrHexa = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, rgb = /^rgb\(((0|[1-9][\d]?|1[\d]{0,2}|2[\d]?|2[0-4][\d]|25[0-5]),){2}(0|[1-9][\d]?|1[\d]{0,2}|2[\d]?|2[0-4][\d]|25[0-5])\)$/, rgba = /^rgba\(((0|[1-9][\d]?|1[\d]{0,2}|2[\d]?|2[0-4][\d]|25[0-5]),){2}(0|[1-9][\d]?|1[\d]{0,2}|2[\d]?|2[0-4][\d]|25[0-5]),(0|0\.[0-9]+[1-9]|0\.[1-9]+|1)\)$/ // Keep in sync with ui/types/api/validation.d.ts export const testPattern = { date: v => /^-?[\d]+\/[0-1]\d\/[0-3]\d$/.test(v), time: v => /^([0-1]?\d|2[0-3]):[0-5]\d$/.test(v), fulltime: v => /^([0-1]?\d|2[0-3]):[0-5]\d:[0-5]\d$/.test(v), timeOrFulltime: v => /^([0-1]?\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/.test(v), // -- RFC 5322 -- // -- Added in v2.6.6 -- // This is a basic helper validation. // For something more complex (like RFC 822) you should write and use your own rule. // We won't be accepting PRs to enhance the one below because of the reason above. // eslint-disable-next-line email: v => /^(([^<>()\[\]\\.,;:\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,}))$/.test(v), hexColor: v => hex.test(v), hexaColor: v => hexa.test(v), hexOrHexaColor: v => hexOrHexa.test(v), rgbColor: v => rgb.test(v), rgbaColor: v => rgba.test(v), rgbOrRgbaColor: v => rgb.test(v) || rgba.test(v), hexOrRgbColor: v => hex.test(v) || rgb.test(v), hexaOrRgbaColor: v => hexa.test(v) || rgba.test(v), anyColor: v => hexOrHexa.test(v) || rgb.test(v) || rgba.test(v) } export default { testPattern }