diff --git a/docs/src/pages/quasar-utils/other-utils.md b/docs/src/pages/quasar-utils/other-utils.md index 05aef22a2ca..75db324d1f8 100644 --- a/docs/src/pages/quasar-utils/other-utils.md +++ b/docs/src/pages/quasar-utils/other-utils.md @@ -90,7 +90,7 @@ The `opts` parameter is optional and can be a String (mimeType) or an Object wit * **mimeType** (optional) - Examples: 'application/octect-stream' (default), 'text/plain', 'application/json', 'text/plain;charset=UTF-8', 'video/mp4', 'image/png', 'application/pdf' + Examples: 'application/octet-stream' (default), 'text/plain', 'application/json', 'text/plain;charset=UTF-8', 'video/mp4', 'image/png', 'application/pdf' [https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) * **byteOrderMark** (optional) @@ -475,3 +475,24 @@ node.addEventListener('click', evt => { event.stopAndPrevent(evt) }) ``` + +## testPattern + +Test against particular patterns. + +```js +import { patterns } from 'quasar' + +const { testPattern } = patterns + +testPattern.email('foo@bar.com') // true +testPattern.email('foo') // false + +testPattern.hexColor('#fff') // true +testPattern.hexColor('#ffffff') // true +testPattern.hexColor('#FFF') // true +testPattern.hexColor('#gggggg') // false + +// See the full list of patterns here: +// https://github.com/quasarframework/quasar/blob/dev/ui/src/utils/patterns.js +``` diff --git a/ui/types/utils.d.ts b/ui/types/utils.d.ts index fb586f85b4e..a13b11eeb56 100644 --- a/ui/types/utils.d.ts +++ b/ui/types/utils.d.ts @@ -18,6 +18,7 @@ export * from "./utils/event"; export * from "./utils/format"; export * from "./utils/scroll"; export * from "./utils/is"; +export * from "./utils/patterns"; export * from "./utils/run-sequential-promises"; import { BrandColor } from "./api/color"; diff --git a/ui/types/utils/patterns.d.ts b/ui/types/utils/patterns.d.ts new file mode 100644 index 00000000000..7ac45183ae2 --- /dev/null +++ b/ui/types/utils/patterns.d.ts @@ -0,0 +1,10 @@ +import { EmbeddedValidationRule } from "../api/validation"; + +interface Patterns { + /** + * Test against particular patterns. + */ + testPattern: Record boolean>; +} + +export declare const patterns: Patterns;