MCPcopy Create free account
hub / github.com/formkit/formkit / parseRule

Function parseRule

packages/validation/src/validation.ts:646–660  ·  view source on GitHub ↗

* Given a rule like confirm:password_confirm produce a FormKitValidationIntent * @param rule - A string representing a validation rule. * @returns

(rule: string)

Source from the content-addressed store, hash-verified

644 * @returns
645 */
646function 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 !

Callers 1

extractRulesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected