IMPORTANT NOTE: This page is massively out of date. In RC3 all validators except for ValidateUnique where shifted to the ValidationComponent, and other ActiveRecord Validators were removed from the ActiveRecord project. This page needs to be updated to reflect that.
Warning: There are some known issues yet to be resolved on using ARValidation with Session Scopes
You can combine validations on your ActiveRecord classes by using ActiveRecordValidationBase instead of ActiveRecordBase.
By doing so, you can use the following methods:
* IsValid: will return true only if all validation test passes
* ValidationErrorMessages: returns a string array of descriptive error messages
Validators
Currently we support the following validations:
* ValidateEmail
* ValidateIsUnique
* ValidateRegExp
* ValidateNonEmpty
It's easy to add your own, though.
Using it
[ActiveRecord] public class Customer : ActiveRecordValidationBase { private String contactName; private String phone; public Customer() { } [Property, ValidateNonEmpty] public string ContactName { get { return contactName; } set { contactName = value; } } [Property, ValidateNonEmpty] public string Phone { get { return phone; } set { phone = value; } } }
If you attempt to save an invalid instance, AR will throw an exception, so calling IsValid is usually a good idea.
