C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
LessThanAttribute.cs
Go to the documentation of this file.
1using System;
2
4{
7 [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
9 {
11 public double LessThanValue { get; private set; }
12
15 public bool CanEqual { get; private set; }
16
23 public LessThanAttribute(double lessThanValue, bool canEqual = false)
24 {
25 CanEqual = canEqual;
26 LessThanValue = lessThanValue;
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 <= LessThanValue : dblValue < LessThanValue;
39 }
40 }
41}
Specifies that the property with this attribute should be less than the specified amount.
double LessThanValue
The number this property should be greater than.
LessThanAttribute(double lessThanValue, bool canEqual=false)
Specifies that the property with this attribute should be less than the specified amount.
bool CanEqual
(Default: False) Set to true if the property can be greater than OR EQUAL to the specified value.
override bool IsValid(object value)
Determines whether the given value passes validation.
Any attribute that can validate the value of a property.
double GetValue(object value)
Gets the double value corresponding to the supplied object.