ArgumentsValidationBuilder
Namespace: MJCZone.MediaMatic.AspNetCore.Validation
Assembly: MJCZone.MediaMatic.AspNetCore
Summary
A builder for validating method arguments with immediate fail-fast behavior.
public
Contents
Constructors (1) | Methods (24)
Constructors
ArgumentsValidationBuilder
Initializes a new instance of the ArgumentsValidationBuilder class.
ArgumentsValidationBuilder()Methods
| Method | Summary |
|---|---|
| NotNull | Validates that an argument is not null. |
| NotNullOrWhiteSpace | Validates that a string argument is not null, empty, or whitespace. |
| NotNullOrEmpty | Validates that a string argument is not null or empty. |
| GreaterThan | Validates that a value is greater than a specified minimum. |
| GreaterThanOrEqual | Validates that a value is greater than or equal to a specified minimum. |
| LessThan | Validates that a value is less than a specified maximum. |
| LessThanOrEqual | Validates that a value is less than or equal to a specified maximum. |
| InRange | Validates that a value is within a specified range. |
| MinLength | Validates that a string has a minimum length. |
| MaxLength | Validates that a string has a maximum length. |
| Matches | Validates that a string value matches a specified regular expression pattern. |
| Object | Validates a complex object using the ObjectValidationBuilder. |
| IsTrue | Validates that a condition is true. |
| IsFalse | Validates that a condition is false. |
| Custom | Performs a custom validation with a condition. |
| IsTrue | Validates that a lazily-evaluated condition is true. |
| IsFalse | Validates that a lazily-evaluated condition is false. |
| Custom | Performs a custom validation with a lazy condition evaluation. |
| Custom | Performs a custom validation with a lazy condition and message evaluation. |
| Assert | Completes the validation chain. This method does nothing as all validations are performed immediatel... |
| GetType | |
| ToString | |
| Equals | |
| GetHashCode |
NotNull
Validates that an argument is not null.
ArgumentsValidationBuilder NotNull(``0 value, string paramName)Parameters
- value (``0) - The value to validate.
- paramName (string) - The name of the parameter.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
NotNullOrWhiteSpace
Validates that a string argument is not null, empty, or whitespace.
ArgumentsValidationBuilder NotNullOrWhiteSpace(string value, string paramName)Parameters
- value (string) - The value to validate.
- paramName (string) - The name of the parameter.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
NotNullOrEmpty
Validates that a string argument is not null or empty.
ArgumentsValidationBuilder NotNullOrEmpty(string value, string paramName)Parameters
- value (string) - The value to validate.
- paramName (string) - The name of the parameter.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
GreaterThan
Validates that a value is greater than a specified minimum.
ArgumentsValidationBuilder GreaterThan(``0 value, ``0 min, string paramName)Parameters
- value (``0) - The value to validate.
- min (``0) - The minimum value (exclusive).
- paramName (string) - The name of the parameter.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
GreaterThanOrEqual
Validates that a value is greater than or equal to a specified minimum.
ArgumentsValidationBuilder GreaterThanOrEqual(
``0 value,
``0 min,
string paramName)Parameters
- value (``0) - The value to validate.
- min (``0) - The minimum value (inclusive).
- paramName (string) - The name of the parameter.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
LessThan
Validates that a value is less than a specified maximum.
ArgumentsValidationBuilder LessThan(``0 value, ``0 max, string paramName)Parameters
- value (``0) - The value to validate.
- max (``0) - The maximum value (exclusive).
- paramName (string) - The name of the parameter.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
LessThanOrEqual
Validates that a value is less than or equal to a specified maximum.
ArgumentsValidationBuilder LessThanOrEqual(``0 value, ``0 max, string paramName)Parameters
- value (``0) - The value to validate.
- max (``0) - The maximum value (inclusive).
- paramName (string) - The name of the parameter.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
InRange
Validates that a value is within a specified range.
ArgumentsValidationBuilder InRange(
``0 value,
``0 min,
``0 max,
string paramName)Parameters
- value (``0) - The value to validate.
- min (``0) - The minimum value (inclusive).
- max (``0) - The maximum value (inclusive).
- paramName (string) - The name of the parameter.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
MinLength
Validates that a string has a minimum length.
ArgumentsValidationBuilder MinLength(
string value,
int minLength,
string paramName,
bool inclusive)Parameters
- value (string) - The value to validate.
- minLength (int) - The minimum length.
- paramName (string) - The name of the parameter.
- inclusive (bool) - Whether the minimum length is inclusive (default: true).
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
MaxLength
Validates that a string has a maximum length.
ArgumentsValidationBuilder MaxLength(
string value,
int maxLength,
string paramName,
bool inclusive)Parameters
- value (string) - The value to validate.
- maxLength (int) - The maximum length.
- paramName (string) - The name of the parameter.
- inclusive (bool) - Whether the maximum length is inclusive (default: true).
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
Matches
Validates that a string value matches a specified regular expression pattern.
ArgumentsValidationBuilder Matches(
string value,
string pattern,
string paramName)Parameters
- value (string) - The value to validate.
- pattern (string) - The regular expression pattern.
- paramName (string) - The name of the parameter.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
Object
Validates a complex object using the ObjectValidationBuilder.
ArgumentsValidationBuilder Object(
``0 item,
string paramName,
ObjectValidationBuilder{``0}} configure)Parameters
- item (``0) - The item to validate.
- paramName (string) - The name of the parameter.
- configure (ObjectValidationBuilder{``0}}) - An action to configure the ObjectValidationBuilder.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
IsTrue
Validates that a condition is true.
ArgumentsValidationBuilder IsTrue(
bool condition,
string paramName,
string message)Parameters
- condition (bool) - The condition that must be true for validation to pass.
- paramName (string) - The name of the parameter.
- message (string) - The error message if validation fails.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
IsFalse
Validates that a condition is false.
ArgumentsValidationBuilder IsFalse(
bool condition,
string paramName,
string message)Parameters
- condition (bool) - The condition that must be false for validation to pass.
- paramName (string) - The name of the parameter.
- message (string) - The error message if validation fails.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
Custom
Performs a custom validation with a condition.
ArgumentsValidationBuilder Custom(
bool condition,
string paramName,
string message)Parameters
- condition (bool) - The condition that must be true for validation to pass.
- paramName (string) - The name of the parameter.
- message (string) - The error message if validation fails.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
IsTrue
Validates that a lazily-evaluated condition is true.
ArgumentsValidationBuilder IsTrue(
Boolean} condition,
string paramName,
string message)Parameters
- condition (Boolean}) - A function that returns true if validation passes.
- paramName (string) - The name of the parameter.
- message (string) - The error message if validation fails.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
IsFalse
Validates that a lazily-evaluated condition is false.
ArgumentsValidationBuilder IsFalse(
Boolean} condition,
string paramName,
string message)Parameters
- condition (Boolean}) - A function that returns true if the condition being tested is true.
- paramName (string) - The name of the parameter.
- message (string) - The error message if validation fails.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
Custom
Performs a custom validation with a lazy condition evaluation.
ArgumentsValidationBuilder Custom(
Boolean} condition,
string paramName,
string message)Parameters
- condition (Boolean}) - A function that returns true if validation passes.
- paramName (string) - The name of the parameter.
- message (string) - The error message if validation fails.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
Custom
Performs a custom validation with a lazy condition and message evaluation.
ArgumentsValidationBuilder Custom(
Boolean} condition,
string paramName,
String} getMessage)Parameters
- condition (Boolean}) - A function that returns true if validation passes.
- paramName (string) - The name of the parameter.
- getMessage (String}) - A function that returns the error message if validation fails.
Returns
Type: ArgumentsValidationBuilder
The current instance for method chaining.
Assert
Completes the validation chain. This method does nothing as all validations are performed immediately (fail-fast), but is provided for API consistency.
void Assert()GetType
GetType()ToString
ToString()Equals
Equals()GetHashCode
GetHashCode()