MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / getFieldValue

Function getFieldValue

packages/core/src/forms/bind.ts:15–37  ·  view source on GitHub ↗
(
  state: S,
  field: keyof S | string,
)

Source from the content-addressed store, hash-verified

13}
14
15function getFieldValue<S extends Record<string, unknown>>(
16 state: S,
17 field: keyof S | string,
18): unknown {
19 if (typeof field !== "string") {
20 return state[field];
21 }
22
23 const path = parseFieldPath(field);
24 if (path.length === 0) {
25 return undefined;
26 }
27
28 let current: unknown = state;
29 for (const segment of path) {
30 if (current === null || typeof current !== "object") {
31 return undefined;
32 }
33 current = (current as Record<string, unknown>)[segment];
34 }
35
36 return current;
37}
38
39function setField<S extends Record<string, unknown>>(
40 prev: Readonly<S>,

Callers 4

bindFunction · 0.85
bindTransformFunction · 0.85
bindCheckedFunction · 0.85
bindSelectFunction · 0.85

Calls 1

parseFieldPathFunction · 0.85

Tested by

no test coverage detected