C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
GreaterThanAttribute.cs
Go to the documentation of this file.
1using System;
2
4{
7 [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
9 {
11 public double GreaterThanValue { get; private set; }
12
15 public bool CanEqual { get; private set; }
16
23 public GreaterThanAttribute(double greaterThanValue, bool canEqual = false)
24 {
25 CanEqual = canEqual;
26 GreaterThanValue = greaterThanValue;
27 }
28
32 public override bool IsValid(object value)
33 {
34 // If this property is nullable and the value is null, we validate true. If user does
35 // not want this nullable to accept a null value, they can use the NotNullAttribute.
36 if (value == null) return true;
37 double dblValue = GetValue(value);
38 return CanEqual ? dblValue >= GreaterThanValue : dblValue > GreaterThanValue;
39 }
40 }
41}
Specifies that the property with this attribute should be greater than the specified amount.
override bool IsValid(object value)
Determines whether the given value passes validation.
GreaterThanAttribute(double greaterThanValue, bool canEqual=false)
Specifies that the property with this attribute should be greater than the specified amount.
bool CanEqual
(Default: False) Set to true if the property can be greater than OR EQUAL to the specified value.
double GreaterThanValue
The number this property should be greater than.
Any attribute that can validate the value of a property.
double GetValue(object value)
Gets the double value corresponding to the supplied object.