Class Value
A manifest model class representing a value to be validated.
Inheritance
Inherited Members
Namespace: CSF.Validation.ManifestModel
Assembly: CSF.Validation.Abstractions.dll
Syntax
public class Value
Remarks
This type roughly corresponds to ManifestItem. The manifest model classes are simplified when compared with the validation manifest and offer only a subset of functionality. Importantly though, manifest model classes such as this are suitable for easy serialization to/from various data formats, such as JSON or relational database tables.
For more information about when and how to use the manifest model, see the article Using the Manifest Model
Properties
| Improve this Doc View SourceAccessorExceptionBehaviour
Gets or sets an optional value which indicates the desired behaviour should the member accessor raise an exception.
Declaration
public ValueAccessExceptionBehaviour? AccessorExceptionBehaviour { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<ValueAccessExceptionBehaviour> |
Remarks
This option will override the behaviour specified at AccessorExceptionBehaviour for the current value, if this property is set to any non-null value.
If this property is set to null then the behaviour at AccessorExceptionBehaviour will be used.
See Also
| Improve this Doc View SourceChildren
Gets or sets a collection of the child values from the current instance.
Declaration
public IDictionary<string, Value> Children { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, Value> |
Remarks
Each value that is directly derived from a member of the current instance is stored in this collection. The collection key is the member name (typically a property name) by which the value is accessed.
This property may not be set to null, and will raise System.ArgumentNullException if an attempt is made to do so.
Examples
If the current Value instance represents an object which has a property named Age
which should be validated, then the Value instance for the Age property would be stored at
Children["Age"]
.
CollectionItemValue
Gets or sets an optional value object which indicates how items within a collection are to be validated.
Declaration
public Value CollectionItemValue { get; set; }
Property Value
Type | Description |
---|---|
Value |
Remarks
If the value representd by the current instance is a collection/enumerable of items then these items may be validated individually. In this scenario, the type of object represented by the current value must be a type that implements System.Collections.Generic.IEnumerable<T> for at least one generic type.
If this property has a non-null value, then the Value will be used to validate each item within that collection.
If the current value does not represent a collection of items to be validated individually then this property must by null.
Id
Gets or sets an identifier for the current value.
Declaration
public string Id { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
The id of a value is not used by the validator, but it provides a way in which developers may track the lifetime of a single item.
There are no technical reasons why they must be, but developers are encouraged to keep Id values unique within a validation manifest, so that they may identify items unambiguously. The default value for this property is the string representation of a newly-generated GUID.
IdentityMemberName
Gets or sets an optional member name which provides the identity value for the current object.
Declaration
public string IdentityMemberName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
PolymorphicValues
Gets or sets a dictionary of polymorphic values, which describe the configuration of a validator for a type which is derived from the validated type of the current Value.
Declaration
public IDictionary<string, Value> PolymorphicValues { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, Value> |
Remarks
Each key of this dictionary must be the name of a System.Type
, as would return
a type instance if used with Type.GetType(string, bool)
.
This means that the key might need to be a full assembly-qualified type name with the correct formatting
for usage with the GetType method.
If this string type name is incorrect then the exception raised upon conversion to a validation
manifest will be the same exception as Type.GetType(string, bool)
would raise,
if the throwOnError
parameter were set to true.
Rules
Gets or sets a collection of rules for the current value.
Declaration
public ICollection<Rule> Rules { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<Rule> |
Remarks
Each rule validates the object represented by the current value instance. To validate values that are accessed via members of that object, add new value instances to the Children property of this instance and add rules to those child value instances.
ValidateRecursivelyAsAncestor
Gets or sets a value which indicates that the current value should represent recursive validation as an ancestor value.
Declaration
public int? ValidateRecursivelyAsAncestor { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Remarks
If null then this value is treated as a normal manifest value. If not null then this value will be treated as a recursive (or re-entrant) validation manifest value. It will be converted as a ManifestItem that is recursive rather than a normal value.
The numeric value of this property (which must be a positive integer if non-null) indicates which level of ancestor Value is used to provide the recursive validation. For example a value of 1 indicates that the immediate parent value should be used as the wrapped value for the recursive manifest value. A value of 2 would indicate the grandparent value.
Methods
| Improve this Doc View SourceToString()
Gets a string representation of the current instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string which represents the current instance. |