MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / validateEntity

Function validateEntity

src/world/validate.ts:102–122  ·  view source on GitHub ↗
(errors: string[], path: string, e: EntityData, seenIds: Set<string>)

Source from the content-addressed store, hash-verified

100// ---- helpers ---------------------------------------------------------------
101
102function validateEntity(errors: string[], path: string, e: EntityData, seenIds: Set<string>): void {
103 if (!e) {
104 errors.push(path + ' is null');
105 return;
106 }
107 if (typeof e.id !== 'string' || e.id.length === 0) {
108 errors.push(path + '.id must be a non-empty string');
109 } else if (seenIds.has(e.id)) {
110 errors.push(path + '.id "' + e.id + '" is duplicated');
111 } else {
112 seenIds.add(e.id);
113 }
114
115 const hasModel = typeof e.modelRef === 'string' && e.modelRef.length > 0;
116 const hasPrefab = typeof e.prefabRef === 'string' && e.prefabRef.length > 0;
117 if (hasModel === hasPrefab) {
118 errors.push(path + ' must have exactly one of modelRef or prefabRef');
119 }
120
121 validateTransform(errors, path + '.transform', e.transform);
122}
123
124function validatePrefabChild(errors: string[], path: string, c: PrefabChild, seenIds: Set<string>): void {
125 if (!c) {

Callers 1

validateWorldFunction · 0.85

Calls 2

validateTransformFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected