Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​ComponentModel.​DataAnnotations.​RangeAttribute
Assembly: System.ComponentModel.Annotations
Inheritance: object → Attribute → ValidationAttribute → RangeAttribute
Specifies the numeric range constraints for the value of a data field.
Properties
public
bool
ConvertValueInInvariantCulture
Gets or sets a value that determines whether any conversions of the value being validated to <see cref="P:System.ComponentModel.DataAnnotations.RangeAttribute.OperandType" /> as set by the <c>type</c> parameter of the <see cref="M:System.ComponentModel.DataAnnotations.RangeAttribute.#ctor(System.Type,System.String,System.String)" /> constructor use the invariant culture or the current culture.
public
object
Maximum
Gets the maximum allowed field value.
public
bool
MaximumIsExclusive
Specifies whether validation should fail for values that are equal to <see cref="P:System.ComponentModel.DataAnnotations.RangeAttribute.Maximum" /> .
public
object
Minimum
Gets the minimum allowed field value.
public
bool
MinimumIsExclusive
Specifies whether validation should fail for values that are equal to <see cref="P:System.ComponentModel.DataAnnotations.RangeAttribute.Minimum" /> .
public
Type
OperandType
Gets the type of the data field whose value must be validated.
public
bool
ParseLimitsInInvariantCulture
Gets or sets a value that determines whether string values for <see cref="P:System.ComponentModel.DataAnnotations.RangeAttribute.Minimum" /> and <see cref="P:System.ComponentModel.DataAnnotations.RangeAttribute.Maximum" /> are parsed using the invariant culture rather than the current culture.
public
string
ErrorMessage
Gets or sets an error message to associate with a validation control if validation fails.
public
string
ErrorMessageResourceName
Gets or sets the error message resource name to use in order to look up the <see cref="P:System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageResourceType" /> property value if validation fails.
public
Type
ErrorMessageResourceType
Gets or sets the resource type to use for error-message lookup if validation fails.
protected
string
ErrorMessageString
Gets the localized validation error message.
public
bool
RequiresValidationContext
Gets a value that indicates whether the attribute requires validation context.
public
object
TypeId
Methods
public
string
FormatErrorMessage​(string name)
Formats the error message that is displayed when range validation fails.
Returns The formatted error message.
name
The name of the field that caused the validation failure.
public
bool
IsValid​(object value)
Checks that the value of the data field is in the specified range.
Returns <see langword="true" /> if the specified value is in the range; otherwise, <see langword="false" /> .
value
The data field value to validate.
public
ValidationResult
GetValidationResult​(object value,
ValidationContext validationContext)
Inherited from ValidationAttribute
Checks whether the specified value is valid with respect to the current validation attribute.
Returns An instance of the <see cref="T:System.ComponentModel.DataAnnotations.ValidationResult" /> class.
value
The value to validate.
validationContext
The context information about the validation operation.
protected
ValidationResult
IsValid​(object value,
ValidationContext validationContext)
Inherited from ValidationAttribute
Validates the specified value with respect to the current validation attribute.
Returns An instance of the <see cref="T:System.ComponentModel.DataAnnotations.ValidationResult" /> class.
value
The value to validate.
validationContext
The context information about the validation operation.
public
void
Validate​(object value,
ValidationContext validationContext)
Inherited from ValidationAttribute
Validates the specified object.
value
The object to validate.
validationContext
The <see cref="T:System.ComponentModel.DataAnnotations.ValidationContext" /> object that describes the context where the validation checks are performed. This parameter cannot be <see langword="null" /> .
public
void
Validate​(object value,
string name)
Inherited from ValidationAttribute
Validates the specified object.
value
The value of the object to validate.
name
The name to include in the error message.
protected
void
Finalize​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object