ValuesAttribute class | QSYS API Reference Guide
Estimated reading time: 4 minutes
Defines ValuesAttribute class
Namespace: ASNA.QSys.Expo.Model Assembly: ASNA.QSys.Expo.Model.dll
Inheritance: Object –> Attribute –> ValidationAttribute
Remarks
The ValuesAttribute class is a specialized class derived from ValidationAttribute that provides meta-data to express VALUES field-level keyword.
The following excerpt of code describes the Subfile field SFSEL, with the possible input values: 2, 3, 5, 7, 9, 10 and 11
public class SFL1_Model : SubfileRecordModel
{
[Values(typeof(Decimal),"00","02","03","05","07","09","10","11")]
[Dec(2, 0)]
public decimal SFSEL { get; set; }
.
.
.
}
This corresponds to the legacy DDS:
0007.00 A R SFL1 SFL
.
.
.
0010.00 A SFSEL 2Y 0B 8 4VALUES(0 2 3 5 7 9 10 11)
Notes:
- The
Valuesattribute requires indication of the type of value it should be used during validation. In this caseDecimal. - The list of possible Values is indicated using string format. Each value will be converted to the indicated type before validation logic runs.
- The first value added during Migration corresponds to the Blanks value (which is the value that represents no input to this field). For character fields a white space is used, for decimal fields the zero (as a string) is used.
Constructors
| Name | Description |
|---|---|
| ValuesAttribute(String[]) | Initializes a new instance of the class ValuesAttribute with the initial valid values provided |
| ValuesAttribute(Int32[]) | Initializes a new instance of the class ValuesAttribute with the initial valid values provided |
| ValuesAttribute(Type, Object[]) | Initializes a new instance of the class ValuesAttribute with the initial type and valid object values provided |
ValuesAttribute(String[])
Initializes a new instance of the class ValuesAttribute with the initial valid values provided
ValuesAttribute(String[])
Parameters
| Type | Parameter name | Description |
|---|---|---|
| String[] | validValues | initial values string array |
ValuesAttribute(Int32[])
Initializes a new instance of the class ValuesAttribute with the initial valid values provided
ValuesAttribute(Int32[])
Parameters
| Type | Parameter name | Description |
|---|---|---|
| Int32[] | validValues | initial values integer array |
ValuesAttribute(Type, Object[])
Initializes a new instance of the class ValuesAttribute with the initial type and valid object values provided
ValuesAttribute(Type, Object[])
Parameters
| Type | Parameter name | Description |
|---|---|---|
| Type | type | type of valid values |
| Object[] | validValues | valid values object array |
Properties
| Type | Name | Description |
|---|---|---|
| Type | ObjectType | Gets the Object Type |
| Boolean | TrimStringValue | Gets or sets a boolean value indicating if the value in the string needs te trimmed |
| Object[] | ValidValues | Gets the array of valid values |
Methods
| Signature | Description |
|---|---|
| FormatErrorMessage(String) | Applies formatting to an error message, based on the data field where the error occurred. |
| GetFrom(MemberInfo) | Gets a ValuesAttribute from the MemberInfo instance provided as input (from object’s custom attributes) |
| IsValid(Object) | Gets a boolean valid indicating that the passed in value is valid |
string FormatErrorMessage(string name)
Applies formatting to an error message, based on the data field where the error occurred.
string FormatErrorMessage(string name)
Parameters
| Type | Parameter name | Description |
|---|---|---|
| String | name | The field name to include in the formatted message. |
Returns
| Type | Description |
|---|---|
| String |
ValuesAttribute GetFrom(MemberInfo member)
Gets a ValuesAttribute from the MemberInfo instance provided as input (from object’s custom attributes)
ValuesAttribute GetFrom(MemberInfo member)
Parameters
| Type | Parameter name | Description |
|---|---|---|
| MemberInfo | member | member information |
Returns
| Type | Description |
|---|---|
| ValuesAttribute | the ValuesAttribute |
bool IsValid(object value)
Gets a boolean valid indicating that the passed in value is valid
bool IsValid(object value)
Parameters
| Type | Parameter name | Description |
|---|---|---|
| Object | value | input value |
Returns
| Type | Description |
|---|---|
| Boolean | true if valid |