ValidateRequired

Description: Indicates a property is required.

Constructor(s):
  • public ValidateRequiredAttribute(string message)

Parameters:
  • message: The message to be used if validation fails.

Example Usage:
public class MyEntity : EvilBaseEntity
{
    [ValidateRequired("Property1 is required.")]
    public string Property1
    {
        // Omitted for brevity
    }
}


Valid Entity:
MyEntity entity = new MyEntity();
entity.Property1 = "SomeValue";

bool result = entity.IsValid();


Invalid Entity 1:
MyEntity entity = new MyEntity();
entity.Property1 = null;

bool result = entity.IsValid();


Invalid Entity 2:
MyEntity entity = new MyEntity();
entity.Property1 = string.Empty;

bool result = entity.IsValid();

Last edited Dec 7, 2006 at 3:10 PM by Arcware, version 1

Comments

No comments yet.