Class ValidationAttribute
- Namespace
- Gamelogic.Extensions
- Assembly
- Gamelogic.Extensions.dll
The base class for properties that can be validated.
[AttributeUsage(AttributeTargets.Field)]
[Version(4, 3, 0)]
public abstract class ValidationAttribute : PropertyAttribute
- Inheritance
-
ValidationAttribute
- Derived
- Inherited Members
- Extension Methods
Remarks
The default behaviour is determined by booleans in PropertyDrawerData: ForceValue, WarnInConsole, and WarnInInspector, but can be overriden for an attribute by setting the properties define in this attribute: ForceValue, WarnInConsole, and WarnInInspector. And since these properties are public, they can be set by the attribute user to override them for a specific field.
This attribute may be applied to multiple types. It is up to subclasses to use the right implement the methods correctly for the types that apply.
Custom SerializableAttribute types are not supported, and an error will be thrown in the editor when you apply this attribute to a field of a custom type.
See Property Drawers for more details.
Properties
- Color
Gets and sets the color to use when drawing the property in the inspector when the value is invalid.
- ForceValue
Gets and sets whether to force the value to be valid, provided the attributes allows it.
- HexColor
Gets and sets the color to use when drawing the property in the inspector when the value is invalid.
- Message
Gets and set the message to display in the inspector or console when the value is invalid.
- WarnInConsole
Gets and sets whether to warn in the console when a value is invalid.
- WarnInInspector
Gets and sets whether to warn in the inspector when a value is invalid.
Methods
- Constrain(SerializedProperty)
Constrains a given value to be valid (i.e. pass IsValid(SerializedProperty)).
- ConstrainAndVerify(SerializedProperty)
Constrain and verify the value of the given property.
- IsValid(SerializedProperty)
Checks whether the given property is valid.