MCPcopy Create free account
hub / github.com/arktypeio/arktype / checkAnnotationValue

Function checkAnnotationValue

ark/sets/fromJsonSchema.ts:1503–1533  ·  view source on GitHub ↗
(
	value: unknown,
	pointer: string,
	depth = 0,
	seen: Set<object> = new Set()
)

Source from the content-addressed store, hash-verified

1501 typeof root.meta.expected === "string" ? root.meta.expected : root.description
1502
1503const checkAnnotationValue = (
1504 value: unknown,
1505 pointer: string,
1506 depth = 0,
1507 seen: Set<object> = new Set()
1508): void => {
1509 if (typeof value !== "object" || value === null) return
1510 if (depth >= maxValueDepth)
1511 throwParseError(writeMaxDepthMessage(pointer, maxValueDepth))
1512 if (seen.has(value)) throwParseError(writeCircularSchemaMessage(pointer))
1513 seen.add(value)
1514 try {
1515 if (isArray(value)) {
1516 for (let i = 0; i < value.length; i++) {
1517 if (i in value)
1518 checkAnnotationValue(value[i], `${pointer}/${i}`, depth + 1, seen)
1519 }
1520 } else {
1521 for (const [key, v] of Object.entries(value)) {
1522 checkAnnotationValue(
1523 v,
1524 `${pointer}/${escapePointer(key)}`,
1525 depth + 1,
1526 seen
1527 )
1528 }
1529 }
1530 } finally {
1531 seen.delete(value)
1532 }
1533}
1534
1535const withAnnotations = (
1536 root: BaseRoot,

Callers 1

withAnnotationsFunction · 0.85

Calls 7

throwParseErrorFunction · 0.90
writeMaxDepthMessageFunction · 0.85
escapePointerFunction · 0.85
hasMethod · 0.45
addMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected