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

Function runRule

packages/validation/src/validation.ts:386–400  ·  view source on GitHub ↗

* Run a validation rule debounced or not. * @param validation - A validation to debounce

(
  validation: FormKitValidation,
  node: FormKitObservedNode,
  after: (result: boolean | Promise<boolean>) => void
)

Source from the content-addressed store, hash-verified

384 * @param validation - A validation to debounce
385 */
386function runRule(
387 validation: FormKitValidation,
388 node: FormKitObservedNode,
389 after: (result: boolean | Promise<boolean>) => void
390) {
391 if (validation.debounce) {
392 validation.timer = setTimeout(() => {
393 node.observe()
394 after(validation.rule(node, ...validation.args))
395 }, validation.debounce) as unknown as number
396 } else {
397 node.observe()
398 after(validation.rule(node, ...validation.args))
399 }
400}
401
402/**
403 * The messages given to this function have already been set on the node, but

Callers 1

runFunction · 0.85

Calls 1

afterFunction · 0.85

Tested by

no test coverage detected