Table of Contents

Class PasswordComplexityBaseAttribute

Namespace
NuvTools.Validation.Annotations
Assembly
NuvTools.Validation.dll

Abstract base class for password complexity validation attributes. Provides common functionality for validating minimum occurrences of specific character types in passwords.

public abstract class PasswordComplexityBaseAttribute : ValidationAttribute
Inheritance
PasswordComplexityBaseAttribute
Derived
Inherited Members
Extension Methods

Constructors

PasswordComplexityBaseAttribute(int, Func<string>)

Abstract base class for password complexity validation attributes. Provides common functionality for validating minimum occurrences of specific character types in passwords.

protected PasswordComplexityBaseAttribute(int minOccurrences, Func<string> errorMessageAccessor)

Parameters

minOccurrences int

The minimum number of occurrences required for the specific character type.

errorMessageAccessor Func<string>

A function that returns the error message to use when validation fails.

Properties

MinOccurrences

Gets the minimum number of occurrences required for the specific character type.

public int MinOccurrences { get; }

Property Value

int

Methods

EnsureLegalMinOcorrences()

Checks that MinOccurrences has a legal value.

protected void EnsureLegalMinOcorrences()

Exceptions

InvalidOperationException

MinOccurrences is zero or less than negative one.

FormatErrorMessage(string)

Applies formatting to a specified error message. (Overrides FormatErrorMessage(string))

public override string FormatErrorMessage(string name)

Parameters

name string

The name to include in the formatted string.

Returns

string

A localized string to describe the minimal occurrences of capital letters.

IsValidValue(object?)

Determines whether the provided value is a valid non-empty string for password validation.

protected static bool IsValidValue(object? value)

Parameters

value object

The value to check.

Returns

bool

True if the value is a non-null, non-empty string; otherwise, false.