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

Function validate

packages/validation/src/validation.ts:243–275  ·  view source on GitHub ↗

* Given parsed validations, a value and a node, run the validations and set * the appropriate store messages on the node. * @param value - The value being validated * @param node - The Node this value belongs to * @param rules - The rules

(
  node: FormKitNode | FormKitObservedNode,
  validations: FormKitValidation[],
  state: FormKitValidationState
)

Source from the content-addressed store, hash-verified

241 * @param rules - The rules
242 */
243function validate(
244 node: FormKitNode | FormKitObservedNode,
245 validations: FormKitValidation[],
246 state: FormKitValidationState
247) {
248 if (isKilled(node)) return
249 state.input = token()
250 node.store.set(
251 createMessage({
252 key: 'failing',
253 value: !state.isPassing,
254 visible: false,
255 })
256 )
257 state.isPassing = true
258 node.store.filter((message) => !message.meta.removeImmediately, 'validation')
259 validations.forEach(
260 (validation) => validation.debounce && clearTimeout(validation.timer)
261 )
262 if (validations.length) {
263 node.store.set(validatingMessage)
264 run(0, validations, state, false, () => {
265 node.store.remove(validatingMessage.key)
266 node.store.set(
267 createMessage({
268 key: 'failing',
269 value: !state.isPassing,
270 visible: false,
271 })
272 )
273 })
274 }
275}
276
277/**
278 * Runs validation rules recursively while collecting dependencies allowing for

Callers 2

rebootFunction · 0.85
createValidationPluginFunction · 0.85

Calls 4

isKilledFunction · 0.90
tokenFunction · 0.90
createMessageFunction · 0.90
runFunction · 0.85

Tested by

no test coverage detected