EV
EasyValidate
  • Home
  • Getting Started
  • Examples
  • Extend EasyValidate
GitHubBuy me coffee
EV
EasyValidate

Attribute-based validation library for .NET with source generation support. Build robust applications with zero reflection overhead.

GitHubNuGet

Documentation

  • Getting Started
  • Attributes
  • Usage Guide
  • Examples

Features

  • Analyzers
  • Fixers
  • Async Validation
  • Parameter Validation

Resources

  • GitHub Repository
  • NuGet Package
  • Issues
  • Discussions

For AI & Developers

  • AI API (JSON)
  • AI Summary
  • OpenAPI Spec
  • LLMs.txt

© 2025 EasyValidate. All rights reserved.

Made withfor the .NET community
🏷️ Attributes Reference

EasyValidate Attributes

Comprehensive guide to all validation attributes available in EasyValidate

5Categories
83Attributes

Date

Date and time validation attributes

20 attributes
AgeRange
Attribute
Validates that a date represents an age within a specified range.

Example Usage

Properties

MinimumAge(int)- The minimum age allowed (inclusive)
MaximumAge(int)- The maximum age allowed (inclusive)
DateRange
Attribute
Validates that a date falls within a specified range.

Example Usage

Properties

Minimum(DateTime)- The minimum date allowed (inclusive)
Maximum(DateTime)- The maximum date allowed (inclusive)
Day
Attribute
Validates that a date falls on one of the specified days of the month.

Example Usage

Properties

Days(int[])- Array of allowed days of the month (1-31)
DayOfWeek
Attribute
Validates that a date falls on one of the specified days of the week.

Example Usage

Properties

Days(DayOfWeek[])- Array of allowed days of the week
FutureDate
Attribute
Validates that a date is in the future.

Example Usage

LeapYear
Attribute
Validates that a date falls in a leap year.

Example Usage

MaxAge
Attribute
Validates that a date represents a maximum age (person must not be older than specified).

Example Usage

Properties

MaximumAge(int)- The maximum age allowed
MinAge
Attribute
Validates that a date represents a minimum age (person must be at least specified age).

Example Usage

Properties

MinimumAge(int)- The minimum age required
Month
Attribute
Validates that a date falls in one of the specified months.

Example Usage

Properties

Months(int[])- Array of allowed months (1-12)
NotInFuture
Attribute
Validates that a date is today or in the past (not in the future).

Example Usage

NotInPast
Attribute
Validates that a date is today or in the future (not in the past).

Example Usage

NotLeapYear
Attribute
Validates that a date does not fall in a leap year.

Example Usage

NotTodayDate
Attribute
Validates that a date is not today's date.

Example Usage

NotUTC
Attribute
Validates that a date is not in UTC format.

Example Usage

PastDate
Attribute
Validates that a date is in the past.

Example Usage

Quarter
Attribute
Validates that a date falls in one of the specified quarters.

Example Usage

Properties

Quarters(Quarter[])- Array of allowed quarters (Q1-Q4)
TimeRange
Attribute
Validates that a time falls within a specified range.

Example Usage

Properties

Minimum(TimeSpan)- The minimum time allowed (inclusive)
Maximum(TimeSpan)- The maximum time allowed (inclusive)
Today
Attribute
Validates that a date is today (ignoring time).

Example Usage

UTC
Attribute
Validates that a date is in UTC format.

Example Usage

Year
Attribute
Validates that a date falls in one of the specified years.

Example Usage

Properties

Years(int[])- Array of allowed years

Collections

Collection validation attributes

10 attributes
ContainsElement
Attribute
Validates that a collection contains the specified value.

Example Usage

Properties

ExpectedValue(object)- The value that must be present in the collection
HasElements
Attribute
Validates that a collection has at least one element.

Example Usage

Length
Attribute
Validates that the collection has exactly the specified number of elements.

Example Usage

Properties

ExpectedLength(uint)- The exact number of elements required
MaxLength
Attribute
Validates that the collection does not exceed a maximum number of elements.

Example Usage

Properties

Maximum(uint)- The maximum number of elements allowed
MinLength
Attribute
Validates that the collection has at least a minimum number of elements.

Example Usage

Properties

Minimum(uint)- The minimum number of elements required
NoNullElements
Attribute
Validates that a collection does not contain any null elements.

Example Usage

NotContainElement
Attribute
Validates that a collection does not contain the specified value.

Example Usage

Properties

ForbiddenValue(object)- The value that must not be in the collection
Single
Attribute
Validates that the specified value appears exactly once in the collection.

Example Usage

Properties

ExpectedValue(object)- The value that must appear exactly once
SingleOrNone
Attribute
Validates that the specified value appears at most once (zero or one time) in the collection.

Example Usage

Properties

ExpectedValue(object)- The value that must appear at most once
UniqueElements
Attribute
Validates that all values in the collection are unique (no duplicates).

Example Usage

General

General purpose validation attributes

5 attributes
EqualTo
Attribute
Validation attribute to ensure a property or field is equal to a specified value.

Example Usage

Properties

ComparisonValue(object)- The value to compare against
NotDefault
Attribute
Validation attribute to ensure a property or field is not set to its default value.

Example Usage

NotEqualTo
Attribute
Validation attribute to ensure a property or field is not equal to a specified value.

Example Usage

Properties

ComparisonValue(object)- The value that is not allowed
NotNull
Attribute
Validation attribute to ensure a property or field is not null.

Example Usage

Optional
Attribute
Validation attribute to mark a property or field as optional (null is allowed).

Example Usage

Numeric

Numeric validation attributes

17 attributes
DivisibleBy
Attribute
Validates that a numeric value is divisible by a specified number.

Example Usage

Properties

Divisor(double)- The value the number must be divisible by
EvenNumber
Attribute
Validates that a numeric value is even.

Example Usage

Fibonacci
Attribute
Validates that a numeric value is a Fibonacci number.

Example Usage

GreaterThan
Attribute
Validates that a numeric value is greater than a specified comparison value.

Example Usage

GreaterThanOrEqualTo
Attribute
Validates that a numeric value is greater than or equal to a specified comparison value.

Example Usage

LessThan
Attribute
Validates that a numeric value is less than a specified comparison value.

Example Usage

LessThanOrEqualTo
Attribute
Validates that a numeric value is less than or equal to a specified comparison value.

Example Usage

MaxDigits
Attribute
Validates that an integer value has at most a specified number of digits.

Example Usage

Properties

Maximum(int)- The maximum number of digits allowed
MinDigits
Attribute
Validates that an integer value has at least a specified number of digits.

Example Usage

Properties

Minimum(int)- The minimum number of digits required
MultipleOf
Attribute
Validates that a numeric value is a multiple of a specified number.

Example Usage

Properties

Factor(double)- The value the number must be a multiple of
Negative
Attribute
Validates that a numeric value is negative (less than zero).

Example Usage

NonZero
Attribute
Validates that a numeric value is not zero.

Example Usage

OddNumber
Attribute
Validates that a numeric value is odd.

Example Usage

Positive
Attribute
Validates that a numeric value is positive (greater than zero).

Example Usage

PowerOf
Attribute
Validates that a numeric value is a power of a specified base.

Example Usage

Properties

Base(int)- The base value for power calculation
Prime
Attribute
Validates that a numeric value is a prime number.

Example Usage

Range
Attribute
Validates that a numeric value is within a specified range.

Example Usage

Properties

Boundary(RangeBoundary)- Inclusive, Exclusive, InclusiveMinExclusiveMax, or ExclusiveMinInclusiveMax

String

String validation attributes

31 attributes
Alpha
Attribute
Validates that a string contains only alphabetic characters (A-Z, a-z).

Example Usage

AlphaNumeric
Attribute
Validates that a string contains only alphanumeric characters (A-Z, a-z, 0-9).

Example Usage

Ascii
Attribute
Validates that a string contains only ASCII characters (0x00-0x7F).

Example Usage

BaseEncoding
Attribute
Validates that a string is a valid Base16, Base32, Base58, Base62, Base64, or Base85 encoded value.

Example Usage

Properties

EncodingType(BaseType)- The encoding type (Base16, Base32, Base58, Base62, Base64, Base85)
Color
Attribute
Validates that a string is a valid color in hexadecimal format.

Example Usage

CommonPrintable
Attribute
Validates that a string contains only common printable characters.

Example Usage

Contains
Attribute
Validates that a string contains a specific substring.

Example Usage

Properties

Comparison(StringComparison)- Optional comparison type (default: OrdinalIgnoreCase)
CreditCard
Attribute
Validates that a string is a valid credit card number (Luhn check).

Example Usage

EmailAddress
Attribute
Validates that a string is a valid email address.

Example Usage

EndsWith
Attribute
Validates that a string ends with the specified suffix.

Example Usage

Properties

Comparison(StringComparison)- Optional comparison type
FileExtension
Attribute
Validates that a string has one of the specified file extensions.

Example Usage

Properties

AllowedExtensions(string[])- Array of allowed extensions
FirstLetterUpper
Attribute
Validates that the first letter of a string is uppercase.

Example Usage

Guid
Attribute
Validates that a string is a valid GUID.

Example Usage

Hex
Attribute
Validates that a string contains only hexadecimal characters (0-9, a-f, A-F).

Example Usage

ISBN
Attribute
Validates that a string is a valid ISBN-10 or ISBN-13.

Example Usage

IpAddress
Attribute
Validates that a string is a valid IPv4 or IPv6 address.

Example Usage

Lowercase
Attribute
Validates that a string is all lowercase.

Example Usage

MacAddress
Attribute
Validates that a string is a valid MAC address.

Example Usage

Matches
Attribute
Validates that a string matches the specified regular expression pattern.

Example Usage

MinLength
Attribute
Validates that a string has at least the specified length.

Example Usage

Properties

Minimum(uint)- The minimum string length required
NoWhitespace
Attribute
Validates that a string does not contain any whitespace.

Example Usage

NotContains
Attribute
Validates that a string does not contain a specific substring.

Example Usage

Properties

Comparison(StringComparison)- Optional comparison type
NotEmpty
Attribute
Validates that a string is not null, empty, or whitespace.

Example Usage

NotOneOf
Attribute
Validates that a string is not one of the specified values.

Example Usage

Properties

ForbiddenValues(string[])- Array of forbidden values
Numeric
Attribute
Validates that a string can be parsed as a number.

Example Usage

OneOf
Attribute
Validates that a string is one of the specified values.

Example Usage

Properties

AllowedValues(string[])- Array of allowed values
Phone
Attribute
Validates that a string is a valid phone number.

Example Usage

StartsWith
Attribute
Validates that a string starts with the specified prefix.

Example Usage

Properties

Comparison(StringComparison)- Optional comparison type
Uppercase
Attribute
Validates that a string is all uppercase.

Example Usage

Url
Attribute
Validates that a string is a valid URL.

Example Usage

ValidEnum
Attribute
Validates that a string matches a valid enum value.

Example Usage

Properties

EnumType(Type)- The enum type to validate against

Ready to see attributes in action?

Check out comprehensive examples and real-world usage scenarios

View ExamplesUsage Guide