Considering the creation of an enum to store various regex patterns in my application for enhanced code reuse.
For example:
export enum Regex {
ONE_PATTERN = /^[example]+$/g,
ANOTHER_PATTERN = /^[test]{5,7}$/g
}
However:
- Encountering the TS90010 error when not using string literals: Type RegExp is not assignable to type Regex.
- Unable to use these patterns in a pattern attribute on inputs if using string literals.
For instance:
<input ngModel="..." pattern="{{ANOTHER_PATTERN}}" .../>
Is this approach advisable for storing regex patterns in this manner?