ValidationStateAttribute Class

 

Apply this attribute to a model element class to control whether its instances are included in validation operations. By default, a model element is validated only if validation is explicitly enabled for a class to which it belongs, using this attribute.

Namespace:   Microsoft.VisualStudio.Modeling.Validation
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)

System::Object
  System::Attribute
    Microsoft.VisualStudio.Modeling.Validation::ValidationStateAttribute

[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true)]
public ref class ValidationStateAttribute sealed : Attribute

NameDescription
System_CAPS_pubmethodValidationStateAttribute(ValidationState)

Apply this attribute to a model element class to control whether its instances are included in validation operations.

NameDescription
System_CAPS_pubpropertyTypeId

(Inherited from Attribute.)

System_CAPS_pubpropertyValidationState

Gets the value of ValidationStateAttribute.

NameDescription
System_CAPS_pubmethodEquals(Object^)

(Inherited from Attribute.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Attribute.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIsDefaultAttribute()

(Inherited from Attribute.)

System_CAPS_pubmethodMatch(Object^)

(Inherited from Attribute.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

This attribute enables or disables validation for each domain type.

The values can be:

  • Enabled

  • Disabled

  • Inherited

  • By default, the validation for a domain type is Inherited. This means that the class will have the same validation behavior as its base class. If there is no explicit base class, the default is Disabled.

Therefore, if you want validation to be applied to model elements, you must explicitly apply this attribute to the domain classes to which they belong.

If you apply the attribute to a base class, you do not need to apply it to derived classes unless you want to exclude them from validation.

For more information, see Validation in a Domain-Specific Language.

The following example shows the ValidationState attribute applied to the Person class, which enables validation for that class.

[C#]

[ValidationState(ValidationState.Enabled)]
public partial class Person
{
    //Code goes here...
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: