* 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 )
| 241 | * @param rules - The rules |
| 242 | */ |
| 243 | function 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 |
no test coverage detected