Add validation for boolean properties in scene document entities
This commit is contained in:
@@ -1124,6 +1124,28 @@ function validateModelInstance(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isBoolean(modelInstance.visible)) {
|
||||||
|
diagnostics.push(
|
||||||
|
createDiagnostic(
|
||||||
|
"error",
|
||||||
|
"invalid-model-instance-visible",
|
||||||
|
"Model instance visible must be a boolean.",
|
||||||
|
`${path}.visible`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isBoolean(modelInstance.enabled)) {
|
||||||
|
diagnostics.push(
|
||||||
|
createDiagnostic(
|
||||||
|
"error",
|
||||||
|
"invalid-model-instance-enabled",
|
||||||
|
"Model instance enabled must be a boolean.",
|
||||||
|
`${path}.enabled`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const asset = document.assets[modelInstance.assetId];
|
const asset = document.assets[modelInstance.assetId];
|
||||||
|
|
||||||
if (asset === undefined) {
|
if (asset === undefined) {
|
||||||
@@ -1167,11 +1189,41 @@ function validateEntityName(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateAuthoredEntityState(
|
||||||
|
entity: EntityInstance,
|
||||||
|
path: string,
|
||||||
|
diagnostics: SceneDiagnostic[]
|
||||||
|
) {
|
||||||
|
if (!isBoolean(entity.visible)) {
|
||||||
|
diagnostics.push(
|
||||||
|
createDiagnostic(
|
||||||
|
"error",
|
||||||
|
"invalid-entity-visible",
|
||||||
|
"Entity visible must remain a boolean.",
|
||||||
|
`${path}.visible`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isBoolean(entity.enabled)) {
|
||||||
|
diagnostics.push(
|
||||||
|
createDiagnostic(
|
||||||
|
"error",
|
||||||
|
"invalid-entity-enabled",
|
||||||
|
"Entity enabled must remain a boolean.",
|
||||||
|
`${path}.enabled`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function validatePlayerStartEntity(
|
function validatePlayerStartEntity(
|
||||||
entity: PlayerStartEntity,
|
entity: PlayerStartEntity,
|
||||||
path: string,
|
path: string,
|
||||||
diagnostics: SceneDiagnostic[]
|
diagnostics: SceneDiagnostic[]
|
||||||
) {
|
) {
|
||||||
|
validateAuthoredEntityState(entity, path, diagnostics);
|
||||||
|
|
||||||
if (!isFiniteVec3(entity.position)) {
|
if (!isFiniteVec3(entity.position)) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
@@ -1752,6 +1804,8 @@ function validateSoundEmitterEntity(
|
|||||||
document: SceneDocument,
|
document: SceneDocument,
|
||||||
diagnostics: SceneDiagnostic[]
|
diagnostics: SceneDiagnostic[]
|
||||||
) {
|
) {
|
||||||
|
validateAuthoredEntityState(entity, path, diagnostics);
|
||||||
|
|
||||||
if (!isFiniteVec3(entity.position)) {
|
if (!isFiniteVec3(entity.position)) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
@@ -1847,6 +1901,8 @@ function validateTriggerVolumeEntity(
|
|||||||
path: string,
|
path: string,
|
||||||
diagnostics: SceneDiagnostic[]
|
diagnostics: SceneDiagnostic[]
|
||||||
) {
|
) {
|
||||||
|
validateAuthoredEntityState(entity, path, diagnostics);
|
||||||
|
|
||||||
if (!isFiniteVec3(entity.position)) {
|
if (!isFiniteVec3(entity.position)) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
@@ -1897,6 +1953,8 @@ function validateTeleportTargetEntity(
|
|||||||
path: string,
|
path: string,
|
||||||
diagnostics: SceneDiagnostic[]
|
diagnostics: SceneDiagnostic[]
|
||||||
) {
|
) {
|
||||||
|
validateAuthoredEntityState(entity, path, diagnostics);
|
||||||
|
|
||||||
if (!isFiniteVec3(entity.position)) {
|
if (!isFiniteVec3(entity.position)) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
@@ -1925,6 +1983,8 @@ function validateInteractableEntity(
|
|||||||
path: string,
|
path: string,
|
||||||
diagnostics: SceneDiagnostic[]
|
diagnostics: SceneDiagnostic[]
|
||||||
) {
|
) {
|
||||||
|
validateAuthoredEntityState(entity, path, diagnostics);
|
||||||
|
|
||||||
if (!isFiniteVec3(entity.position)) {
|
if (!isFiniteVec3(entity.position)) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
@@ -1958,13 +2018,13 @@ function validateInteractableEntity(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isBoolean(entity.enabled)) {
|
if (!isBoolean(entity.interactionEnabled)) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
"error",
|
"error",
|
||||||
"invalid-interactable-enabled",
|
"invalid-interactable-interaction-enabled",
|
||||||
"Interactable enabled must remain a boolean.",
|
"Interactable interactionEnabled must remain a boolean.",
|
||||||
`${path}.enabled`
|
`${path}.interactionEnabled`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1975,6 +2035,8 @@ function validateSceneEntryEntity(
|
|||||||
path: string,
|
path: string,
|
||||||
diagnostics: SceneDiagnostic[]
|
diagnostics: SceneDiagnostic[]
|
||||||
) {
|
) {
|
||||||
|
validateAuthoredEntityState(entity, path, diagnostics);
|
||||||
|
|
||||||
if (!isFiniteVec3(entity.position)) {
|
if (!isFiniteVec3(entity.position)) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
@@ -2003,6 +2065,8 @@ function validateSceneExitEntity(
|
|||||||
path: string,
|
path: string,
|
||||||
diagnostics: SceneDiagnostic[]
|
diagnostics: SceneDiagnostic[]
|
||||||
) {
|
) {
|
||||||
|
validateAuthoredEntityState(entity, path, diagnostics);
|
||||||
|
|
||||||
if (!isFiniteVec3(entity.position)) {
|
if (!isFiniteVec3(entity.position)) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
@@ -2036,13 +2100,13 @@ function validateSceneExitEntity(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isBoolean(entity.enabled)) {
|
if (!isBoolean(entity.interactionEnabled)) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
"error",
|
"error",
|
||||||
"invalid-scene-exit-enabled",
|
"invalid-scene-exit-interaction-enabled",
|
||||||
"Scene Exit enabled must remain a boolean.",
|
"Scene Exit interactionEnabled must remain a boolean.",
|
||||||
`${path}.enabled`
|
`${path}.interactionEnabled`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2631,6 +2695,28 @@ export function validateSceneDocument(
|
|||||||
|
|
||||||
registerAuthoredId(brush.id, path, seenIds, diagnostics);
|
registerAuthoredId(brush.id, path, seenIds, diagnostics);
|
||||||
|
|
||||||
|
if (!isBoolean(brush.visible)) {
|
||||||
|
diagnostics.push(
|
||||||
|
createDiagnostic(
|
||||||
|
"error",
|
||||||
|
"invalid-box-visible",
|
||||||
|
"Box brush visible must remain a boolean.",
|
||||||
|
`${path}.visible`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isBoolean(brush.enabled)) {
|
||||||
|
diagnostics.push(
|
||||||
|
createDiagnostic(
|
||||||
|
"error",
|
||||||
|
"invalid-box-enabled",
|
||||||
|
"Box brush enabled must remain a boolean.",
|
||||||
|
`${path}.enabled`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (brush.name !== undefined && brush.name.trim().length === 0) {
|
if (brush.name !== undefined && brush.name.trim().length === 0) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
|
|||||||
Reference in New Issue
Block a user