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

Function validatePrefabChild

src/world/validate.ts:124–144  ·  view source on GitHub ↗
(errors: string[], path: string, c: PrefabChild, seenIds: Set<string>)

Source from the content-addressed store, hash-verified

122}
123
124function validatePrefabChild(errors: string[], path: string, c: PrefabChild, seenIds: Set<string>): void {
125 if (!c) {
126 errors.push(path + ' is null');
127 return;
128 }
129 if (typeof c.id !== 'string' || c.id.length === 0) {
130 errors.push(path + '.id must be a non-empty string');
131 } else if (seenIds.has(c.id)) {
132 errors.push(path + '.id "' + c.id + '" is duplicated');
133 } else {
134 seenIds.add(c.id);
135 }
136
137 const hasModel = typeof c.modelRef === 'string' && c.modelRef.length > 0;
138 const hasPrefab = typeof c.prefabRef === 'string' && c.prefabRef.length > 0;
139 if (hasModel === hasPrefab) {
140 errors.push(path + ' must have exactly one of modelRef or prefabRef');
141 }
142
143 validateTransform(errors, path + '.transform', c.transform);
144}
145
146function validateTransform(errors: string[], path: string, t: TransformData): void {
147 if (!t) {

Callers 1

validatePrefabFunction · 0.85

Calls 2

validateTransformFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected