Compile-Time Safety

Parameter Validation

EasyValidate automatically generates validation methods for your method parameters and constructors using attributes. Get compile-time safety with zero runtime reflection overhead.

6Examples
6Methods

Real Examples from EasyValidate

See actual parameter validation in action with real code from the EasyValidate test suite.

Basic Parameter Validation
Apply validation attributes to method parameters for automatic validation.
NotNull ValidationParameter AttributesAutomatic GenerationType Safety
Constructor Validation
Generate factory methods with validation for constructors - perfect for creating validated instances.
Constructor ValidationFactory MethodsImmutable ObjectsStatic Generation
GeneratedMethod Attribute
Customize generated method names and access modifiers using the GeneratedMethod attribute.
Custom Method NamesAccess ModifiersConstructor & Method SupportFlexible API
Pass-Through Parameters
Methods can have parameters without validation - they're passed through to the original method.
Mixed ParametersPass-Through SupportFlexible ValidationClean API
Calling Validated Methods
Choose between the original method (no validation) or the generated validation overload.
Method OverloadingValidation ResultsError HandlingBackward Compatible
Access Modifier Options
Control the visibility of generated validation methods using the AccessModifier enum.
PublicInternalProtectedPrivateFine-Grained Control

Validation Process Flow

Understand how EasyValidate processes validation chains and handles errors.

Method Validation Flow
How EasyValidate processes method parameter validation.

Call Validation Overload

Call the generated method with ValidationConfig parameter

Validate Parameters

Each parameter with attributes is validated in sequence

Execute Original

If all validations pass, original method is called

Return Result

IValidationResult with the method's return value

Constructor Validation Flow
How EasyValidate generates factory methods for constructor validation.

Call Factory Method

Call the static Create (or custom named) factory method

Validate Parameters

Constructor parameters with attributes are validated

Create Instance

If valid, constructor is called to create the instance

Return Result

IValidationResult<T> containing the new instance

Error Handling Flow
What happens when validation fails at any step in the chain.

Validation Fails

Any validation attribute returns invalid result

Short-Circuit

Remaining validations in chain are skipped for performance

Error Details

Detailed error information including attribute and value

Result Returned

IValidationResult with IsValid = false and error details