(errors: string[], path: string, e: EntityData, seenIds: Set<string>)
| 100 | // ---- helpers --------------------------------------------------------------- |
| 101 | |
| 102 | function 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 | |
| 124 | function validatePrefabChild(errors: string[], path: string, c: PrefabChild, seenIds: Set<string>): void { |
| 125 | if (!c) { |
no test coverage detected