* 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)
| 1919 | * @internal |
| 1920 | */ |
| 1921 | function 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. |