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

Function validateCellOrValueSchema

docs/pseudo.esm.sh/tinybase@9.0.0/index.js:1098–1121  ·  view source on GitHub ↗
(schema)

Source from the content-addressed store, hash-verified

1096 );
1097 const validateValuesSchema = (valuesSchema) => objValidate(valuesSchema, validateCellOrValueSchema);
1098 const validateCellOrValueSchema = (schema) => {
1099 if (!objValidate(
1100 schema,
1101 (_child, id2) => arrayHas([TYPE, DEFAULT, ALLOW_NULL], id2)
1102 )) {
1103 return false;
1104 }
1105 const type = schema[TYPE];
1106 if (!isTypeStringOrBoolean(type) && type != NUMBER && !isJsonType(type)) {
1107 return false;
1108 }
1109 const defaultValue = schema[DEFAULT];
1110 if (isNull(defaultValue) && !schema[ALLOW_NULL]) {
1111 return false;
1112 }
1113 if (!isNull(defaultValue)) {
1114 if (getCellOrValueType(defaultValue) != type) {
1115 objDel(schema, DEFAULT);
1116 } else {
1117 schema[DEFAULT] = encodeIfJson(defaultValue);
1118 }
1119 }
1120 return true;
1121 };
1122 const validateContent = isArray;
1123 const validateTables = (tables) => objValidate(tables, validateTable, cellInvalid);
1124 const validateTable = (table, tableId) => (!hasTablesSchema || collHas(tablesSchemaMap, tableId) || /* istanbul ignore next */

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…