MCPcopy
hub / github.com/tinyplex/tinybase / validateCellOrValueSchema

Function validateCellOrValueSchema

src/store/index.ts:367–391  ·  view source on GitHub ↗
(schema: CellSchema | ValueSchema)

Source from the content-addressed store, hash-verified

365 ): boolean => objValidate(valuesSchema, validateCellOrValueSchema);
366
367 const validateCellOrValueSchema = (schema: CellSchema | ValueSchema) => {
368 if (
369 !objValidate(schema, (_child, id: Id) =>
370 arrayHas([TYPE, DEFAULT, ALLOW_NULL], id),
371 )
372 ) {
373 return false;
374 }
375 const type = schema[TYPE];
376 if (!isTypeStringOrBoolean(type) && type != NUMBER && !isJsonType(type)) {
377 return false;
378 }
379 const defaultValue = schema[DEFAULT];
380 if (isNull(defaultValue) && !schema[ALLOW_NULL]) {
381 return false;
382 }
383 if (!isNull(defaultValue)) {
384 if (getCellOrValueType(defaultValue) != type) {
385 objDel(schema as any, DEFAULT);
386 } else {
387 (schema as any)[DEFAULT] = encodeIfJson(defaultValue as Cell);
388 }
389 }
390 return true;
391 };
392
393 const validateContent = isArray;
394

Callers

nothing calls this directly

Calls 8

objValidateFunction · 0.90
arrayHasFunction · 0.90
isTypeStringOrBooleanFunction · 0.90
isJsonTypeFunction · 0.90
isNullFunction · 0.90
getCellOrValueTypeFunction · 0.90
objDelFunction · 0.90
encodeIfJsonFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…