* Checks if the specified nullable string value matches the given pattern. * @param value The nullable string value to check, or a Promise resolving to the * nullable string value. * @param pattern The pattern the value is expected to match. If `pattern` is a string, * `value` is exp
(
value: string | null | Promise<string | null>,
pattern: string | RegExp | null,
)
| 631 | * @return Whether the value matches the pattern. |
| 632 | */ |
| 633 | static async stringMatches( |
| 634 | value: string | null | Promise<string | null>, |
| 635 | pattern: string | RegExp | null, |
| 636 | ): Promise<boolean> { |
| 637 | value = await value; |
| 638 | if (pattern === null) { |
| 639 | return value === null; |
| 640 | } else if (value === null) { |
| 641 | return false; |
| 642 | } |
| 643 | return typeof pattern === 'string' ? value === pattern : pattern.test(value); |
| 644 | } |
| 645 | |
| 646 | /** |
| 647 | * Adds a predicate function to be run against candidate harnesses. |