C# Class RequiredIfAttribute, code

Inheritance: ValidationAttribute, IClientValidatable
Show file Open project: shendongnian/code Class Usage Examples

Public Methods

Method Description
FormatErrorMessage ( string name ) : string

Applies formatting to an error message, based on the data field where the error occurred.

RequiredIfAttribute ( string otherProperty, object otherPropertyValue )

Initializes a new instance of the RequiredIfAttribute class.

Protected Methods

Method Description
IsValid ( object value, ValidationContext, validationContext ) : ValidationResult,

Validates the specified value with respect to the current validation attribute.

Method Details

FormatErrorMessage() public method

Applies formatting to an error message, based on the data field where the error occurred.
public FormatErrorMessage ( string name ) : string
name string The name to include in the formatted message.
return string

IsValid() protected method

Validates the specified value with respect to the current validation attribute.
protected IsValid ( object value, ValidationContext, validationContext ) : ValidationResult,
value object The value to validate.
validationContext ValidationContext, The context information about the validation operation.
return ValidationResult,

RequiredIfAttribute() public method

Initializes a new instance of the RequiredIfAttribute class.
public RequiredIfAttribute ( string otherProperty, object otherPropertyValue )
otherProperty string The other property.
otherPropertyValue object The other property value.