This documentation is archived and is not being maintained.

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.

  ClassDescription
Public classValidationContextContains information about the current validation processing being performed.
Public classValidationControllerContains logic to validate a single model element or all model elements in a store or partition.
Public classValidationMessageRepresents a validation message that states an error, a warning, or a message.
Public classValidationMessageObserverReports errors, messages, and warnings that are generated from validation methods.
Public classValidationMethodAttributeRepresents an attribute that can be used during validation.
Public classValidationStateAttributeIndicates whether you can validate the domain type to which you applied the attribute.

  EnumerationDescription
Public enumerationValidationCategoriesThis 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 enumerationValidationStateIdentifies whether instances of a class will be enabled for validation.
Public enumerationViolationTypeRepresents the type of violation that has occurred during validation.
Show: