MCPcopy Create free account
hub / github.com/clientdb/clientdb / validateEntityDataProp

Function validateEntityDataProp

engine/schema/validate.ts:30–47  ·  view source on GitHub ↗
(
  prop: string,
  value: unknown,
  schema: SchemaEntity
)

Source from the content-addressed store, hash-verified

28}
29
30export function validateEntityDataProp(
31 prop: string,
32 value: unknown,
33 schema: SchemaEntity
34) {
35 const attribute = schema.attributes.find((a) => a.name === prop);
36 if (!attribute) {
37 throw new Error(`Attribute ${prop} not found in entity ${schema.name}`);
38 }
39
40 if (attribute.isNullable && (value === null || value === undefined)) {
41 return;
42 }
43
44 if (!getIsDataTypeValid(value, attribute.type)) {
45 throw new Error(`Attribute ${prop} has invalid type ${attribute.type}`);
46 }
47}
48
49export function validateEntityData(
50 data: Record<any, any>,

Callers 2

validateEntityDataFunction · 0.85
validateEntityUpdateDataFunction · 0.85

Calls 2

getIsDataTypeValidFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected