Validate a Model¶
The Validator is the equivalent of a spelling checker: it can check that each item in a model has all of the information it needs, but it can’t check whether it means what you intend it to.
Thus even if a model is valid, it could still be the equivalent of correctly-spelled nonsense.
Validate a model against the CellML specification
// Validate the model: check for syntactic and semantic errors.
// Create a Validator instance and pass the model for checking.
auto validator = libcellml::Validator::create();
validator->validateModel(model);
auto isValid = validator->errorCount() == 0;
printIssues(validator);
Full context: example_simulationToolDev.cpp
# Validate the model: check for syntactic and semantic errors.
# Create a Validator instance and pass the model for checking.
validator = Validator()
validator.validateModel(model)
print_issues_to_terminal(validator)
Full context: example_simulationToolDev.py
Once a model has been passed to a Validator instance, the validator’s internal logger will contain a list of any of the issues which have been encountered during the checking process.
A model can be said to be valid - that is, conforming to the CellML normative specification - if the validator’s logger contains no issues with a level of ERROR.
For more information on how to use any of the classes which record issues, please see the Get Issues section.