Password

Overview

The CPassword class is designed to verify the strength and validity of passwords based on predefined rules such as minimum length, the inclusion of special characters, numbers, and uppercase and lowercase letters.

Features

  • Length Check: Ensures passwords meet minimum and maximum length criteria.

  • Character Diversity: Validates the presence of digits, uppercase letters, lowercase letters, and special characters.

Usage

// Create a CPassword instance with specific rules
var validator = new CPassword(
    minLength: 8,
    maxLength: 15,
    requireDigit: true,
    requireLowercase: true,
    requireUppercase: true,
    requireNonAlphanumeric: true,
    allowedSpecialCharacters: "!@#$%^&*"
);

// A sample password to validate
validator.Value = "Example$1";

// Perform validation
bool isValid = validator.CheckValidations();

Console.WriteLine($"Password is valid: {isValid}");

Methods

  • CheckValidations() -> bool: Checks if the given password meets all the specified criteria.

Last updated

Was this helpful?