EV
EasyValidate
  • Home
  • Getting Started
  • Examples
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

© 2025 EasyValidate. All rights reserved.

Made withfor the .NET community
🏷️ Attributes Reference

EasyValidate Attributes

Comprehensive guide to all validation attributes available in EasyValidate

5Categories
86Attributes

Date

Date and time validation attributes

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

Example Usage

Properties

BirthDate(DateTime)- BirthDate property
DateOfBirth(DateTime)- DateOfBirth property
DateRange
Attribute
Validates that a date falls within a specified range.

Example Usage

Properties

EventDate(DateTime)- EventDate property
ProjectDate(DateTime)- ProjectDate property
DateValidation
Attribute
Base attribute for date validation attributes. Provides a contract for validating DateTime properties.

Example Usage

Day
Attribute
Validates that a date falls on one of the specified days of the month.

Example Usage

Properties

PaymentDate(DateTime)- PaymentDate property
MonthlyReport(DateTime)- MonthlyReport property
DayOfWeek
Attribute
Validates that a date falls on one of the specified days of the week.

Example Usage

Properties

WorkDay(DateTime)- WorkDay property
WeekendEvent(DateTime)- WeekendEvent property
FutureDate
Attribute
Validates that a date is in the future.

Example Usage

Properties

EventDate(DateTime)- EventDate property
ExpiryDate(DateTime)- ExpiryDate property
LeapYear
Attribute
Validates that a date falls in a leap year.

Example Usage

Properties

SpecialDate(DateTime)- SpecialDate property
EventDate(DateTime)- EventDate property
MaxAge
Attribute
Validates that a date represents a maximum age.

Example Usage

Properties

EmployeeBirthDate(DateTime)- EmployeeBirthDate property
ParticipantBirthDate(DateTime)- ParticipantBirthDate property
MinAge
Attribute
Validates that a date represents a minimum age.

Example Usage

Properties

BirthDate(DateTime)- BirthDate property
DateOfBirth(DateTime)- DateOfBirth property
Month
Attribute
Validates that a date falls in one of the specified months.

Example Usage

Properties

VacationDate(DateTime)- VacationDate property
WinterEvent(DateTime)- WinterEvent property
NotInFuture
Attribute
Validates that a date is today or in the past (not in the future).

Example Usage

Properties

BirthDate(DateTime)- BirthDate property
PurchaseDate(DateTime)- PurchaseDate property
NotInPast
Attribute
Validates that a date is today or in the future (not in the past).

Example Usage

Properties

EventDate(DateTime)- EventDate property
ExpiryDate(DateTime)- ExpiryDate property
NotLeapYear
Attribute
Validates that a date does not fall in a leap year.

Example Usage

Properties

StandardYear(DateTime)- StandardYear property
EventDate(DateTime)- EventDate property
NotTodayDate
Attribute
Validates that a date is not today's date.

Example Usage

Properties

ScheduledDate(DateTime)- ScheduledDate property
HistoricalDate(DateTime)- HistoricalDate property
NotUTC
Attribute
Validates that a date is not in UTC format.

Example Usage

Properties

LocalTime(DateTime)- LocalTime property
UserTimestamp(DateTime)- UserTimestamp property
Chain(string)- Chain property
ConditionalMethod(string)- ConditionalMethod property
PastDate
Attribute
Validates that a date is in the past.

Example Usage

Properties

BirthDate(DateTime)- BirthDate property
CompletedDate(DateTime)- CompletedDate property
Quarter
Attribute
Represents the quarters of a year.

Example Usage

Properties

ReportDate(DateTime)- ReportDate property
YearEndDate(DateTime)- YearEndDate property
TimeRange
Attribute
Validates that a time falls within a specified range.

Example Usage

Properties

WorkingHours(DateTime)- WorkingHours property
EveningEvent(DateTime)- EveningEvent property
Today
Attribute
Validates that a date is today (ignoring time).

Example Usage

Properties

CheckInDate(DateTime)- CheckInDate property
TransactionDate(DateTime)- TransactionDate property
UTC
Attribute
Validates that a date is in UTC format.

Example Usage

Properties

CreatedAt(DateTime)- CreatedAt property
LogTimestamp(DateTime)- LogTimestamp property
Chain(string)- Chain property
ConditionalMethod(string)- ConditionalMethod property
Year
Attribute
Validates that a date falls in one of the specified years.

Example Usage

Properties

EventDate(DateTime)- EventDate property
HistoricalDate(DateTime)- HistoricalDate property

Collections

Collection validation attributes

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

Example Usage

Properties

Numbers(int[])- Numbers property
ErrorMessage(string)- ErrorMessage property
HasElements
Attribute
Validates that a collection has at least one element.

Example Usage

Properties

Names(string[])- Names property
ErrorMessage(string)- ErrorMessage property
Length
Attribute
Validates that the collection has exactly the specified number of elements.

Example Usage

Properties

Numbers(int[])- Numbers property
ErrorMessage(string)- ErrorMessage property
MaxLength
Attribute
Validates that the collection does not exceed a maximum number of elements.

Example Usage

Properties

Categories(string[])- Categories property
ErrorMessage(string)- ErrorMessage property
MinLength
Attribute
Validates that the collection has at least a minimum number of elements.

Example Usage

Properties

Options(string[])- Options property
ErrorMessage(string)- ErrorMessage property
NoNullElements
Attribute
Validates that a collection does not contain any null elements.

Example Usage

Properties

Tags(string[])- Tags property
ErrorMessage(string)- ErrorMessage property
NotContainElement
Attribute
Validates that a collection does not contain the specified value.

Example Usage

Properties

NonZeroNumbers(int[])- NonZeroNumbers property
ErrorMessage(string)- ErrorMessage property
Single
Attribute
Validates that the specified value appears exactly once in the collection.

Example Usage

Properties

Numbers(int[])- Numbers property
ErrorMessage(string)- ErrorMessage property
SingleOrNone
Attribute
Validates that the specified value appears at most once (zero or one time) in the collection.

Example Usage

Properties

Flags(int[])- Flags property
ErrorMessage(string)- ErrorMessage property
UniqueElements
Attribute
Validates that all values in the collection are unique.

Example Usage

Properties

Tags(string[])- Tags property
ErrorMessage(string)- ErrorMessage property

General

General purpose validation attributes

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

Example Usage

Properties

UserType(string)- UserType property
MinimumAge(int)- MinimumAge property
GeneralValidation
Attribute
Base class for all general validation attributes.

Example Usage

NotDefault
Attribute
Validation attribute to ensure a property or field is not set to its default value.

Example Usage

Properties

Id(Guid)- Id property
Count(int)- Count property
NotEqualTo
Attribute
Validation attribute to ensure a property or field is not equal to a specified value.

Example Usage

Properties

Username(string)- Username property
Score(int)- Score property
NotNull
Attribute
Validation attribute to ensure a property or field is not null.

Example Usage

Properties

Name(string)- Name property
Optional
Attribute
Validation attribute to mark a property or field as optional (null is allowed, no error is reported). Inherits from NotNullAttribute but overrides the strategy and error message to allow null values.

Example Usage

Properties

Nickname(string)- Nickname property

Numeric

Numeric validation attributes

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

Example Usage

Properties

Quantity(int)- Quantity property
ErrorMessage(string)- ErrorMessage property
EvenNumber
Attribute
Validates that a numeric value is even.

Example Usage

Properties

PlayerNumber(int)- PlayerNumber property
BatchSize(int)- BatchSize property
ErrorMessage(string)- ErrorMessage property
Fibonacci
Attribute
Validates that a numeric value is a Fibonacci number.

Example Usage

Properties

SpecialNumber(int)- SpecialNumber property
Sequence(long)- Sequence property
ErrorMessage(string)- ErrorMessage property
GreaterThan
Attribute
Validates that a numeric value is greater than a specified comparison value.

Example Usage

Properties

Score(int)- Score property
Temperature(double)- Temperature property
ErrorMessage(string)- ErrorMessage property
GreaterThanOrEqualTo
Attribute
Validates that a numeric value is greater than or equal to a specified comparison value.

Example Usage

Properties

Quantity(int)- Quantity property
MinimumAge(double)- MinimumAge property
ErrorMessage(string)- ErrorMessage property
LessThan
Attribute
Validates that a numeric value is less than a specified comparison value.

Example Usage

Properties

Score(int)- Score property
Temperature(double)- Temperature property
ErrorMessage(string)- ErrorMessage property
LessThanOrEqualTo
Attribute
Validates that a numeric value is less than or equal to a specified comparison value.

Example Usage

Properties

Percentage(int)- Percentage property
MaxPrice(double)- MaxPrice property
ErrorMessage(string)- ErrorMessage property
MaxDigits
Attribute
Validates that an integer value has at most a specified number of digits.

Example Usage

Properties

Percentage(int)- Percentage property
ErrorMessage(string)- ErrorMessage property
MinDigits
Attribute
Validates that an integer value has at least a specified number of digits.

Example Usage

Properties

Pin(int)- Pin property
ErrorMessage(string)- ErrorMessage property
MultipleOf
Attribute
Validates that a numeric value is a multiple of a specified number.

Example Usage

Properties

Quantity(int)- Quantity property
Measurement(double)- Measurement property
ErrorMessage(string)- ErrorMessage property
Negative
Attribute
Validates that a numeric value is negative (less than zero).

Example Usage

Properties

Deficit(int)- Deficit property
Loss(double)- Loss property
ErrorMessage(string)- ErrorMessage property
NotZero
Attribute
Validates that a numeric value is not zero.

Example Usage

Properties

Divisor(int)- Divisor property
Coefficient(double)- Coefficient property
ErrorMessage(string)- ErrorMessage property
NumericValidation
Attribute
Base attribute for numeric validation attributes. Provides a contract for validating numeric properties.

Example Usage

OddNumber
Attribute
Validates that a numeric value is odd.

Example Usage

Properties

PlayerNumber(int)- PlayerNumber property
LuckyNumber(int)- LuckyNumber property
ErrorMessage(string)- ErrorMessage property
Positive
Attribute
Validates that a numeric value is positive (greater than zero).

Example Usage

Properties

Quantity(int)- Quantity property
Price(double)- Price property
ErrorMessage(string)- ErrorMessage property
PowerOf
Attribute
Validates that a numeric value is a power of a specified base.

Example Usage

Properties

BufferSize(int)- BufferSize property
Multiplier(long)- Multiplier property
ErrorMessage(string)- ErrorMessage property
Prime
Attribute
Validates that a numeric value is a prime number (for integer values only).

Example Usage

Properties

SpecialNumber(int)- SpecialNumber property
KeyValue(int)- KeyValue property
ErrorMessage(string)- ErrorMessage property
Range
Attribute
Validates that a numeric value is within a specified range, with configurable inclusivity/exclusivity for each bound.

Example Usage

Properties

Percentage(int)- Percentage property
Age(int)- Age property
Probability(double)- Probability property
ErrorMessage(string)- ErrorMessage property

String

String validation attributes

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

Example Usage

Properties

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

Example Usage

Properties

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

Example Usage

Properties

Code(string)- Code property
SystemPath(string)- SystemPath property
BaseEncoding
Attribute
Validates that a string is a valid Base16, Base32, Base58, Base62, Base64, or Base85 encoded value.

Example Usage

Properties

EncodedData(string)- EncodedData property
HexData(string)- HexData property
Color
Attribute
Validates that a string is a valid color in hexadecimal format.

Example Usage

Properties

BackgroundColor(string)- BackgroundColor property
BorderColor(string)- BorderColor property
CommonPrintable
Attribute
Validates that a string contains only common printable characters (letters, digits, punctuation, and space).

Example Usage

Properties

DisplayName(string)- DisplayName property
Description(string)- Description property
Contains
Attribute
Validates that a string contains a specific substring.

Example Usage

Properties

Email(string)- Email property
EndpointUrl(string)- EndpointUrl property
Comparison(StringComparison)- Comparison property
CreditCard
Attribute
Validates that a string is a valid credit card number (basic Luhn check).

Example Usage

Properties

CardNumber(string)- CardNumber property
PaymentCard(string)- PaymentCard property
EmailAddress
Attribute
Validates that a string is a valid email address.

Example Usage

Properties

Email(string)- Email property
ContactEmail(string)- ContactEmail property
EndsWith
Attribute
Validates that a string ends with the specified suffix.

Example Usage

Properties

Email(string)- Email property
DocumentPath(string)- DocumentPath property
Comparison(StringComparison)- Comparison property
FileExtension
Attribute
Validates that a string has a specific file extension.

Example Usage

Properties

ImagePath(string)- ImagePath property
DocumentPath(string)- DocumentPath property
FirstLetterUpper
Attribute
Validates that the first letter of a string is uppercase.

Example Usage

Properties

FirstName(string)- FirstName property
Title(string)- Title property
Guid
Attribute
Validates that a string is a valid GUID (Globally Unique Identifier).

Example Usage

Properties

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

Example Usage

Properties

ColorCode(string)- ColorCode property
HashValue(string)- HashValue property
ISBN
Attribute
Validates that a string is a valid ISBN-10 or ISBN-13.

Example Usage

Properties

BookCode(string)- BookCode property
ProductISBN(string)- ProductISBN property
IpAddress
Attribute
Validates that a string is a valid IPv4 or IPv6 address.

Example Usage

Properties

ServerIp(string)- ServerIp property
ClientAddress(string)- ClientAddress property
Lowercase
Attribute
Validates that a string is all lowercase.

Example Usage

Properties

Username(string)- Username property
EmailPrefix(string)- EmailPrefix property
MacAddress
Attribute
Validates that a string is a valid MAC address.

Example Usage

Properties

NetworkCard(string)- NetworkCard property
DeviceIdentifier(string)- DeviceIdentifier property
Matches
Attribute
Validates that a string matches the specified regular expression pattern.

Example Usage

Properties

PhoneNumber(string)- PhoneNumber property
ProductCode(string)- ProductCode property
NoWhitespace
Attribute
Validates that a string does not contain any whitespace.

Example Usage

Properties

ApiKey(string)- ApiKey property
Identifier(string)- Identifier property
NotContains
Attribute
Validates that a string does not contain a specific substring.

Example Usage

Properties

Username(string)- Username property
ProductionCode(string)- ProductionCode property
Comparison(StringComparison)- Comparison property
NotEmpty
Attribute
Validates that a string is not null, empty, or whitespace.

Example Usage

Properties

Name(string)- Name property
Email(string)- Email property
NotOneOf
Attribute
Validates that a string is not one of the specified values.

Example Usage

Properties

Username(string)- Username property
SqlQuery(string)- SqlQuery property
Numeric
Attribute
Validates that a string can be parsed as a number (int, double, decimal, etc).

Example Usage

Properties

Amount(string)- Amount property
Percentage(string)- Percentage property
Chain(string)- Chain property
ConditionalMethod(string)- ConditionalMethod property
ErrorCode(string)- ErrorCode property
OneOf
Attribute
Validates that a string is one of the specified values.

Example Usage

Properties

Status(string)- Status property
Size(string)- Size property
Phone
Attribute
Validates that a string is a valid phone number (basic international/US format check).

Example Usage

Properties

ContactNumber(string)- ContactNumber property
EmergencyContact(string)- EmergencyContact property
StartsWith
Attribute
Validates that a string starts with the specified prefix.

Example Usage

Properties

WebsiteUrl(string)- WebsiteUrl property
Title(string)- Title property
Comparison(StringComparison)- Comparison property
StringValidation
Attribute
Base class for string validation attributes. Provides a contract for validating string properties such as emails, URLs, patterns, length, and content.

Example Usage

Uppercase
Attribute
Validates that a string is all uppercase.

Example Usage

Properties

CountryCode(string)- CountryCode property
Status(string)- Status property
Url
Attribute
Validates that a string is a valid URL.

Example Usage

Properties

Homepage(string)- Homepage property
Chain(string)- Chain property
ConditionalMethod(string)- ConditionalMethod property
ErrorCode(string)- ErrorCode property
ValidEnum
Attribute
Validates that a string matches a valid enum value.

Example Usage

Properties

UserStatus(string)- UserStatus property
WorkDay(string)- WorkDay property

Ready to see attributes in action?

Check out comprehensive examples and real-world usage scenarios

View ExamplesUsage Guide