MCPcopy Index your code
hub / github.com/tinyplex/tinybase / unwrapSchemaWithDefaults

Function unwrapSchemaWithDefaults

src/schematizers/schematizer-arktype/index.ts:103–118  ·  view source on GitHub ↗
(
  schema: any,
  defaultValue?: any,
  allowNull?: boolean,
)

Source from the content-addressed store, hash-verified

101};
102
103const unwrapSchemaWithDefaults = (
104 schema: any,
105 defaultValue?: any,
106 allowNull?: boolean,
107): [any, any, boolean] => {
108 if (isArray(schema) && size(schema) === 3 && schema[1] === '=') {
109 const schemaValue = (schema[0] as any)?.json ?? schema[0];
110 return unwrapSchema(schemaValue, schema[2], allowNull);
111 }
112
113 if (schema?.[_VALUE] && !isUndefined(schema?.[DEFAULT])) {
114 return unwrapSchema(schema[_VALUE], schema[DEFAULT], allowNull);
115 }
116
117 return unwrapSchema(schema, defaultValue, allowNull);
118};
119
120export const createArkTypeSchematizer: typeof createArkTypeSchematizerDecl =
121 () => createCustomSchematizer(unwrapSchemaWithDefaults, getProperties);

Callers

nothing calls this directly

Calls 4

isArrayFunction · 0.90
sizeFunction · 0.90
isUndefinedFunction · 0.90
unwrapSchemaFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…