Microsoft.VisualStudio.Modeling.Validation Namespace

The Microsoft.VisualStudio.Modeling.Validation namespace provides classes that you can use to check a model for valid data and consistency between its elements. Validation is integrated into Visual Studio so that errors, warnings, and messages detected during validation appear in the Error List window.

You can specify that validation occurs when the user opens a model, saves a model, or clicks a validation option from a shortcut menu. You can also write code to define an action that you want to occur when the user invokes custom validation.

You enable validation on a class in the model by decorating the class with an attribute. You can then write any number of validation methods and decorate them with an attribute that indicates when the method should be called when validation is processed. The attribute can signify that the method should be called when the user opens the model, saves the model, runs validation from the shortcut menu, invokes custom validation, or performs any combination of these tasks.

If you are an experienced author of domain-specific languages, you might want to implement your own custom validation by defining classes that inherit from the validation classes.

For more information, see Walkthrough: Adding Validation to a Domain Model.

Classes

  Class Description
Public class ValidationContext Contains information about the current validation processing being performed.
Public class ValidationController Contains logic to validate a single model element or all model elements in a store or partition.
Public class ValidationMessage Represents a validation message that states an error, a warning, or a message.
Public class ValidationMessageObserver Reports errors, messages, and warnings that are generated from validation methods.
Public class ValidationMethodAttribute Represents an attribute that can be used during validation.
Public class ValidationStateAttribute Indicates whether you can validate the domain type to which you applied the attribute.

Enumerations

  Enumeration Description
Public enumeration ValidationCategories This enumeration is a parameter for the constructor of the custom attribute, ValidationMethodAttribute. It specifies the type of validation in which the rule will be invoked.
Public enumeration ValidationState Identifies whether instances of a class will be enabled for validation.
Public enumeration ViolationType Represents the type of violation that has occurred during validation.