IEmptyCheckable.IsEmpty Property
In This Article
Gets if the IEmptyCheckable value is considered to be empty when validating via the RuleRequiredFieldAttribute.
Namespace: DevExpress.Persistent.Validation
Assembly: DevExpress.Persistent.Base.v24.2.dll
NuGet Package: DevExpress.Persistent.Base
#Declaration
#Remarks
Support the IEmptyCheckable interface and implement the IsEmpty method, when it is required to validate properties of your custom type via the RuleRequiredField attribute. Below is the snippet from the Business Class Library’s FileData class, illustrating the implementation of this property:
public class FileData : BaseObject, IFileData, IEmptyCheckable {
// ...
public virtual string FileName { get; set; }
// ...
[Browsable(false)]
public bool IsEmpty {
get { return string.IsNullOrEmpty(FileName); }
}
}
// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.
With the IEmptyCheckable interface supported, the property of the FileData type can be validated in the following manner:
public class Resume : BaseObject {
// ...
[RuleRequiredField("RuleRequiredField for Resume.FileData",
DefaultContexts.Save, ,"The file must be specified"]
public virtual FileData File { get; set; }
// ...
}
// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.
See Also