* Given a rule like confirm:password_confirm produce a FormKitValidationIntent * @param rule - A string representing a validation rule. * @returns
(rule: string)
| 644 | * @returns |
| 645 | */ |
| 646 | function parseRule(rule: string): FormKitValidationIntent | false { |
| 647 | const trimmed = rule.trim() |
| 648 | if (trimmed) { |
| 649 | const matches = trimmed.match(ruleExtractor) |
| 650 | if (matches && typeof matches[1] === 'string') { |
| 651 | const ruleName = matches[1].trim() |
| 652 | const args = |
| 653 | matches[2] && typeof matches[2] === 'string' |
| 654 | ? matches[2].split(',').map((s) => s.trim()) |
| 655 | : [] |
| 656 | return [ruleName, ...args] |
| 657 | } |
| 658 | } |
| 659 | return false |
| 660 | } |
| 661 | |
| 662 | /** |
| 663 | * Given a rule name, detect if there are any additional hints like ! |