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

Function getValidatedCell

src/store/index.ts:429–458  ·  view source on GitHub ↗
(
    tableId: Id,
    rowId: Id | undefined,
    cellId: Id,
    cell: Cell,
  )

Source from the content-addressed store, hash-verified

427 );
428
429 const getValidatedCell = (
430 tableId: Id,
431 rowId: Id | undefined,
432 cellId: Id,
433 cell: Cell,
434 ): CellOrUndefined =>
435 hasTablesSchema
436 ? ifNotUndefined(
437 mapGet(mapGet(tablesSchemaMap, tableId), cellId),
438 (cellSchema) =>
439 isNull(cell)
440 ? cellSchema[ALLOW_NULL]
441 ? cell
442 : cellInvalid(tableId, rowId, cellId, cell, cellSchema[DEFAULT])
443 : getCellOrValueType(cell) === cellSchema[TYPE]
444 ? encodeIfJson(cell)
445 : isJsonType(cellSchema[TYPE]) && isEncodedJson(cell)
446 ? cell
447 : cellInvalid(
448 tableId,
449 rowId,
450 cellId,
451 cell,
452 cellSchema[DEFAULT],
453 ),
454 () => cellInvalid(tableId, rowId, cellId, cell),
455 )
456 : isUndefined(getCellOrValueType(cell))
457 ? cellInvalid(tableId, rowId, cellId, cell)
458 : encodeIfJson(cell);
459
460 const validateValues = (values: Values, skipDefaults?: 1): boolean =>
461 objValidate(

Callers 3

validateRowFunction · 0.70
applyRowDirectlyFunction · 0.70
setCellFunction · 0.70

Calls 8

mapGetFunction · 0.90
isNullFunction · 0.90
getCellOrValueTypeFunction · 0.90
encodeIfJsonFunction · 0.90
isJsonTypeFunction · 0.90
isEncodedJsonFunction · 0.90
isUndefinedFunction · 0.90
cellInvalidFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…