ValidateWorldDocument ( document[,intended_file$] )

Parameters

document - world document handle

intended_file$ (optional) - Save As destination used to resolve relative asset paths

Description

Returns a JSON validation report for a world document.

The caller-owned report contains valid, diagnostics, and counts. Validation never mutates the document.

Each of the world's assets whose file is missing is an error, world.asset.source.missing, at the asset's source ($.assets[n].source), with or without a workspace, and so is a missing file that one of its resources names. The document can still be edited and saved; LoadWorldAsync fails on it unless it uses WORLD_LOAD_PLACEHOLDERS.

For the full story, see the Debug World Editor guide.


See also: SaveWorldDocument, WorldDocumentDiagnostics, WorldDocumentJson.

Example

; ValidateWorldDocument Example
; -----------------------------

; Validation reports on the document without changing it
document=CreateWorldDocument("validate-example","Validate Example")
If document=0 Then RuntimeError WorldDocumentError()

report=ValidateWorldDocument(document,"validate-example.world")
If report=0 Then RuntimeError WorldDocumentError()

valid=JsonObjectGet(report,"valid")
diagnostics=JsonObjectGet(report,"diagnostics")
Print "Valid: "+JsonBoolean(valid)
Print "Diagnostics: "+JsonCount(diagnostics)
Print "Revision after validating (unchanged): "+WorldDocumentRevision(document)

FreeJson diagnostics
FreeJson valid
FreeJson report
FreeWorldDocument document

Print ""
Print "Press any key to close the example"
WaitKey

End

Index