Skip to content

ArgumentsValidationBuilder ​

Namespace: MJCZone.DapperMatic.AspNetCore.Validation

Assembly: MJCZone.DapperMatic.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.

csharp
ArgumentsValidationBuilder()

Methods ​

MethodSummary
NotNullValidates that an argument is not null.
NotNullOrWhiteSpaceValidates that a string argument is not null, empty, or whitespace.
NotNullOrEmptyValidates that a string argument is not null or empty.
GreaterThanValidates that a value is greater than a specified minimum.
GreaterThanOrEqualValidates that a value is greater than or equal to a specified minimum.
LessThanValidates that a value is less than a specified maximum.
LessThanOrEqualValidates that a value is less than or equal to a specified maximum.
InRangeValidates that a value is within a specified range.
MinLengthValidates that a string has a minimum length.
MaxLengthValidates that a string has a maximum length.
MatchesValidates that a string value matches a specified regular expression pattern.
ObjectValidates a complex object using the ObjectValidationBuilder.
IsTrueValidates that a condition is true.
IsFalseValidates that a condition is false.
CustomPerforms a custom validation with a condition.
IsTrueValidates that a lazily-evaluated condition is true.
IsFalseValidates that a lazily-evaluated condition is false.
CustomPerforms a custom validation with a lazy condition evaluation.
CustomPerforms a custom validation with a lazy condition and message evaluation.
AssertCompletes 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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
void Assert()

GetType ​

csharp
GetType()

ToString ​

csharp
ToString()

Equals ​

csharp
Equals()

GetHashCode ​

csharp
GetHashCode()