Main Content

validate

Class: target.Object
Namespace: target

Validate data integrity of target feature object

Syntax

myTargetFeature.validate()

Description

myTargetFeature.validate() runs a procedure to validate the data integrity of the object myTargetFeature. If the validation procedure fails, the method produces an error.

Examples

expand all

To validate the data integrity of target objects, use the IsValid property or the validate method of the target.Object base class.

Consider an example where you create a target.Processor object and associate an existing language implementation with the object.

myProcessor = target.create("Processor");
myProcessor.LanguageImplementations = target.get("LanguageImplementation", ...
                                              "ARM Compatible-ARM Cortex");

To see that the newly created object is not valid, enter myProcessor.IsValid.

myProcessor.IsValid
ans = logical
   0

If you try to validate the object with the method myProcessor.validate(), you get an error.

myProcessor.validate()
Error using target.internal.Processor/validate
Target data validation failed.
 * Undefined property "Name" in "Processor" object.
 * Undefined identifier in "Processor" object.

The validation fails because these target.Processor properties are not specified:

  • Name — Processor name

  • Id — Object identifier

You can specify a processor name, which also specifies the object identifier.

myProcessor.Name = "MyProcessor";

Check the validity of myProcessor again to see that the validity of the object is established.

myProcessor.IsValid
ans = logical
   1

myProcessor.validate()

Note: When you use the target.add function to register a target object, the software also checks the validity of the object.

Version History

Introduced in R2019b