@player-ui/common-types-plugin 0.3.1-next.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import type { Expression } from '@player-ui/types';
2
+ import { resolveDataRefs } from '@player-ui/player';
2
3
  import type { ValidatorFunction } from '@player-ui/player';
3
4
 
4
5
  // Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin http://projects.scottsplayground.com/email_address_validation/
@@ -177,12 +178,13 @@ export const regex: ValidatorFunction<{
177
178
  return;
178
179
  }
179
180
 
181
+ const resolvedRegex = resolveDataRefs(options.regex, context);
180
182
  // Split up /pattern/flags into [pattern, flags]
181
- const patternMatch = options.regex.match(/^\/(.*)\/(\w)*$/);
183
+ const patternMatch = resolvedRegex.match(/^\/(.*)\/(\w)*$/);
182
184
 
183
185
  const regexp = patternMatch
184
186
  ? new RegExp(patternMatch[1], patternMatch[2])
185
- : new RegExp(options.regex);
187
+ : new RegExp(resolvedRegex);
186
188
 
187
189
  if (!regexp.test(value)) {
188
190
  const message = context.constants.getConstants(