All docs
V21.2
21.2
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
The page you are viewing does not exist in version 19.2.
19.1
The page you are viewing does not exist in version 19.1.
18.2
The page you are viewing does not exist in version 18.2.
18.1
The page you are viewing does not exist in version 18.1.
17.2
The page you are viewing does not exist in version 17.2.
.NET Standard 2.0+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET 5.0+

XAF0009: Properties decorated with the RuleRequiredFieldAttribute should be of nullable or reference type

Severity: Error

XAF requires that the properties decorated with the RuleRequiredFieldAttribute attribute must be of nullable or reference type. Otherwise, the validation rule does not work.

This diagnostic works only for XPO and EF Core business classes.

Examples

Invalid Code

using System; 
using DevExpress.Persistent.Validation; 

namespace TestApplication.Module.BusinessObjects { 
    public enum TitleOfCourtesy { Dr, Miss, Mr, Mrs,  Ms }; 

    public class TestClass { 
        public TestClass() { }

        int testValueProperty;
        // The property must be nullable
        //[RuleRequiredField] // Error: XAF0009 
        //public int TestValueProperty {get; set;} 

        TitleOfCourtesy testEnumProperty;
        // The property must be nullable or of reference type
        //[RuleRequiredField] // Error: XAF0009 
        //public TitleOfCourtesy TestEnumProperty {get; set;} 
    } 
} 

Valid Code

using System;
using DevExpress.Persistent.Validation;

namespace TestApplication.Module.BusinessObjects {

    public class ReferenceClass { }

    public class TestClass {
        public TestClass{} { }

        int? TestIntProperty;
        // The property that meets the requirements
        [RuleRequiredField]
        public int? TestIntProperty {get; set;}

        ReferenceClass testReferenceProperty;
        // The property that meets the requirements
        [RuleRequiredField]
        public ReferenceClass TestReferenceProperty {get; set;}
    }
}

How to Fix

Check the business object’s property declaration and ensure the property is of nullable or reference type.