ValidateInput is used on any property, and allows to validate input from inspector.

Use this to enforce correct values.

namespace Sirenix.OdinInspector
[AttributeUsageAttribute((AttributeTargets)384, AllowMultiple = True, Inherited = True)]
public sealed class ValidateInputAttribute : Attribute


Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector

See Also


Definition Description
ValidateInputAttribute(string, string, InfoMessageType) Initializes a new instance of the ValidateInputAttribute class.
ValidateInputAttribute(string, string, InfoMessageType, bool) Obsolete. Rejecting invalid input is no longer supported. Use the other constructors instead.


Return Type Definition Description
string DefaultMessage Default message for invalid values.
bool IncludeChildren Whether to also trigger validation when changes to child values happen. This is true by default.
string MemberName Name of callback function to validate input. The function must have at least one parameter of the same type as the property.
InfoMessageType MessageType The type of the message.


The following examples shows how a speed value can be forced to be above 0.

public class MyComponent : MonoBehaviour
	public float Speed;

	// Specify custom output message and message type.
	[ValidateInput("ValidateInput", "Health must be more than 0!", InfoMessageType.Warning)]
	public float Health;

	private bool ValidateInput(float property)
		return property > 0f;


The following example shows how a static function could also be used.

public class MyComponent : MonoBehaviour
	public int MyInt;

	private static bool StaticValidateFunction(int property)
		return property != 0;