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

Function getValidatedValue

src/store/index.ts:475–493  ·  view source on GitHub ↗
(valueId: Id, value: Value)

Source from the content-addressed store, hash-verified

473 );
474
475 const getValidatedValue = (valueId: Id, value: Value): ValueOrUndefined =>
476 hasValuesSchema
477 ? ifNotUndefined(
478 mapGet(valuesSchemaMap, valueId),
479 (valueSchema) =>
480 isNull(value)
481 ? valueSchema[ALLOW_NULL]
482 ? value
483 : valueInvalid(valueId, value, valueSchema[DEFAULT])
484 : getCellOrValueType(value) === valueSchema[TYPE]
485 ? encodeIfJson(value)
486 : isJsonType(valueSchema[TYPE]) && isEncodedJson(value)
487 ? value
488 : valueInvalid(valueId, value, valueSchema[DEFAULT]),
489 () => valueInvalid(valueId, value),
490 )
491 : isUndefined(getCellOrValueType(value))
492 ? valueInvalid(valueId, value)
493 : encodeIfJson(value);
494
495 const addDefaultsToRow = (row: Row, tableId: Id, rowId?: Id): Row => {
496 ifNotUndefined(

Callers 2

validateValuesFunction · 0.70
setValueFunction · 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
valueInvalidFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…