Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
quasar/ui/src/utils/patterns.js /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (33 sloc)
1.67 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 | |
| } |