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

Function validateInput

packages/core/src/node.ts:1921–1934  ·  view source on GitHub ↗

* Validate that the current input is allowed. * * @param node - A FormKitNode | FormKitNode * @param value - The value that is being validated * * @returns `T` * * @internal

(node: FormKitNode, value: T)

Source from the content-addressed store, hash-verified

1919 * @internal
1920 */
1921function validateInput<T>(node: FormKitNode, value: T): T {
1922 switch (node.type) {
1923 // Inputs are allowed to have any type
1924 case 'input':
1925 break
1926 case 'group':
1927 if (!value || typeof value !== 'object') error(107, [node, value])
1928 break
1929 case 'list':
1930 if (!Array.isArray(value)) error(108, [node, value])
1931 break
1932 }
1933 return value
1934}
1935
1936/**
1937 * Commits the working value to the node graph as the value of this node.

Callers 1

inputFunction · 0.85

Calls 1

errorFunction · 0.90

Tested by

no test coverage detected