DocsDocumentation

Nitro Validate

Standalone, dependency-free data validation with 51+ built-in rules.

A powerful, standalone, dependency-free data validation library for Python with extensible rules and a clean, intuitive API.

Requirements

Python 3.7 or higher is required.

Installation

pip install nitro-validator

AI Assistant Integration

Add Nitro Validator knowledge to your AI coding assistant:

npx skills add nitrosh/nitro-validate

This enables AI assistants like Claude Code to understand Nitro Validator and generate correct validation code.

Features

  • Simple API - Easy to learn with minimal boilerplate
  • Zero Dependencies - No external dependencies required
  • Extensible - Create custom validation rules with ease
  • Clean Syntax - Pipe-delimited rule strings or rule objects
  • Custom Messages - Override default error messages per field or rule
  • Cross-field Validation - Validate fields against other fields
  • Type Safe - Validates strings, numbers, booleans, dates, and more
  • Comprehensive Rules - 51+ built-in validation rules

Quick Start

from nitro_validator import NitroValidator

# Create a validator instance
validator = NitroValidator()

# Define your data and rules
data = {
    'email': '[email protected]',
    'age': 25,
    'password': 'secret123',
    'confirm_password': 'secret123'
}

rules = {
    'email': 'required|email',
    'age': 'required|numeric|min:18',
    'password': 'required|min:8',
    'confirm_password': 'required|same:password'
}

# Validate
try:
    validated_data = validator.validate(data, rules)
    print("Validation passed!", validated_data)
except NitroValidationError as e:
    print("Validation failed:", e.errors)

Note: For convenience, you can also use Validator as an alias for NitroValidator, and ValidationError for NitroValidationError.

Available Rules

Basic Rules

RuleDescriptionExample
requiredField must be present and not empty'email': 'required'
optionalField is optional (always passes)'middle_name': 'optional'

String Rules

RuleDescriptionExample
alphaOnly alphabetic characters'name': 'alpha'
alphanumericOnly alphanumeric characters'username': 'alphanumeric'
alpha_dashLetters, numbers, dashes, underscores'slug': 'alpha_dash'
lowercaseOnly lowercase characters'code': 'lowercase'
uppercaseOnly uppercase characters'code': 'uppercase'
emailValid email address'email': 'email'
urlValid URL'website': 'url'
uuidValid UUID'id': 'uuid'
ipValid IP address (v4 or v6)'address': 'ip'
ipv4Valid IPv4 address'address': 'ipv4'
ipv6Valid IPv6 address'address': 'ipv6'
jsonValid JSON string'data': 'json'
slugValid URL slug'slug': 'slug'
asciiOnly ASCII characters'text': 'ascii'
base64Valid base64 encoding'encoded': 'base64'
hex_colorValid hex color code'color': 'hex_color'
credit_cardValid credit card number'card': 'credit_card'
mac_addressValid MAC address'mac': 'mac_address'
timezoneValid timezone identifier'tz': 'timezone'
localeValid locale code'locale': 'locale'
regex:patternMatches regex pattern'code': 'regex:^[A-Z]{3}$'
starts_with:strStarts with substring'name': 'starts_with:Mr'
ends_with:strEnds with substring'file': 'ends_with:.pdf'
contains:strContains substring'text': 'contains:hello'

Numeric Rules

RuleDescriptionExample
numericMust be numeric'price': 'numeric'
integerMust be an integer'quantity': 'integer'
positiveMust be positive number'amount': 'positive'
negativeMust be negative number'deficit': 'negative'
min:valueMinimum value or length'age': 'min:18'
max:valueMaximum value or length'rating': 'max:5'
between:min,maxBetween two values'score': 'between:0,100'
divisible_by:nDivisible by number'even': 'divisible_by:2'

Comparison Rules

RuleDescriptionExample
same:fieldMust match another field'password_confirm': 'same:password'
different:fieldMust differ from another field'new_email': 'different:old_email'
in:val1,val2Must be in list of values'role': 'in:admin,user,guest'
not_in:val1,val2Must not be in list'status': 'not_in:banned,deleted'

Boolean Rules

RuleDescriptionExample
booleanMust be a boolean value'active': 'boolean'

Date Rules

RuleDescriptionExample
dateMust be a valid date'birthdate': 'date'
before:dateDate must be before'start': 'before:2025-12-31'
after:dateDate must be after'end': 'after:2024-01-01'
date_equals:dateDate must equal'today': 'date_equals:2024-11-23'
date_format:fmtDate must match format'date': 'date_format:%Y-%m-%d'

Note: The date, before, after, and date_equals rules accept unambiguous ISO 8601 formats only (YYYY-MM-DD, YYYY/MM/DD, and datetime variants like YYYY-MM-DDTHH:MM:SS). For specific regional formats like DD-MM-YYYY or MM-DD-YYYY, use the date_format rule with an explicit format string.

Convenience Rules

RuleDescriptionExample
confirmedMatches {field}_confirmation'password': 'confirmed'
acceptedMust be accepted (yes/true/1/on)'terms': 'accepted'
declinedMust be declined (no/false/0/off)'marketing': 'declined'

Length Rules

RuleDescriptionExample
length:valueExact length'zip_code': 'length:5'

Collection Rules

RuleDescriptionExample
arrayMust be a list or tuple'items': 'array'
size:nExact size (length)'tags': 'size:3'
distinctArray must have unique values'ids': 'distinct'

Usage Examples

Basic Validation

from nitro_validator import NitroValidator, NitroValidationError

validator = NitroValidator()

data = {'username': 'johndoe', 'age': '25'}
rules = {'username': 'required|alphanumeric', 'age': 'required|integer|min:18'}

try:
    validated = validator.validate(data, rules)
    print(validated)  # {'username': 'johndoe', 'age': '25'}
except NitroValidationError as e:
    print(e.errors)

Custom Error Messages

# Single message for all rules on a field
messages = {
    'email': 'Please provide a valid email address'
}

# Or specific messages per rule
messages = {
    'password': {
        'required': 'Password is required',
        'min': 'Password must be at least 8 characters'
    }
}

validator.validate(data, rules, messages)

Using Rule Objects

from nitro_validator import Validator, RequiredRule, EmailRule, MinRule

validator = Validator()

data = {'email': '[email protected]', 'age': 25}
rules = {
    'email': [RequiredRule(), EmailRule()],
    'age': [RequiredRule(), MinRule(18)]
}

validated = validator.validate(data, rules)

Check Validation Without Exception

validator = Validator()

if validator.is_valid(data, rules):
    print("Data is valid!")
else:
    print("Errors:", validator.get_errors())

Factory Method

from nitro_validator import Validator

# Create and validate in one call
try:
    validator = Validator.make(data, rules)
    print("Valid:", validator.validated_data)
except ValidationError as e:
    print("Errors:", e.errors)

Creating Custom Rules

Extend the NitroValidationRule class to create custom validation rules:

from nitro_validator import NitroValidationRule, NitroValidator

class StrongPasswordRule(NitroValidationRule):
    """Validate that a password is strong."""

    name = "strong_password"
    message = "The {field} must contain uppercase, lowercase, numbers, and symbols."

    def validate(self, field: str, value: Any, data: dict) -> bool:
        if not value:
            return True

        has_upper = any(c.isupper() for c in value)
        has_lower = any(c.islower() for c in value)
        has_digit = any(c.isdigit() for c in value)
        has_symbol = any(c in '!@#$%^&*()_+-=' for c in value)

        return has_upper and has_lower and has_digit and has_symbol


# Register and use the custom rule
validator = NitroValidator()
validator.register_rule(StrongPasswordRule)

data = {'password': 'MyP@ssw0rd!'}
rules = {'password': 'required|strong_password'}

validated = validator.validate(data, rules)

Backward Compatibility: You can also use Rule as an alias for NitroValidationRule for convenience.

Advanced Usage

Cross-field Validation

# Validate that one field matches another
data = {
    'password': 'secret123',
    'password_confirmation': 'secret123'
}

rules = {
    'password': 'required|min:8',
    'password_confirmation': 'required|same:password'
}

validator.validate(data, rules)

Conditional Validation

# Validate email only if user type is 'customer'
data = {'user_type': 'customer', 'email': '[email protected]'}

if data.get('user_type') == 'customer':
    rules = {'email': 'required|email'}
else:
    rules = {'email': 'optional'}

validator.validate(data, rules)

Handling Validation Errors

from nitro_validator import ValidationError

try:
    validator.validate(data, rules)
except ValidationError as e:
    # Get all errors as a dictionary
    print(e.errors)  # {'email': ['Email is required'], 'age': ['Age must be at least 18']}

    # Or get flattened list of all error messages
    flat_errors = validator.get_errors_flat()
    print(flat_errors)  # ['Email is required', 'Age must be at least 18']

Custom Rule Registry

from nitro_validator import Validator, RuleRegistry

# Create a custom registry
registry = RuleRegistry()
registry.register(MyCustomRule)

# Use it with a validator
validator = Validator(registry=registry)

Examples

The examples/ directory contains working examples:

python examples/basic_usage.py
python examples/custom_rules.py
python examples/advanced_validation.py
python examples/date_validation.py
python examples/formats.py

Development

Setup

git clone https://github.com/nitrosh/nitro-validate.git
cd nitro-validate
pip install -e ".[dev]"

Run Tests

pytest
pytest --cov=nitro_validator

Format Code

black nitro_validator tests examples

Why Nitro Validator?

  • No Dependencies: Unlike other validation libraries, Nitro Validator has zero external dependencies
  • Extensible: Easy to create and register custom validation rules
  • Clean API: Simple, intuitive syntax that's easy to learn and use
  • Pythonic: Follows Python best practices and idioms
  • Well-tested: Comprehensive test suite with high code coverage
  • Type-safe: Works with strings, numbers, booleans, dates, and custom types

Comparison with GUMP

Nitro Validator is inspired by GUMP (a PHP validation library by the same author) but redesigned for Python with:

  • More Pythonic API and conventions
  • Better extensibility with the Rule class system
  • Cleaner error handling with custom exceptions
  • Type hints and modern Python features
  • No external dependencies (GUMP requires PHP extensions)

Ecosystem

  • nitro-cli - Static site generator that builds sites with Python code
  • nitro-ui - Build HTML with Python, not strings
  • nitro-datastore - Schema-free JSON data store with dot notation access
  • nitro-dispatch - Framework-agnostic plugin system
  • nitro-image - Fast, friendly image processing for the web

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.

API Reference

Auto-generated from the installed package's public API. Signatures and docstrings come directly from the source.

Validator

NitroValidator#

NitroValidator(registry: 'NitroRuleRegistry' = None)

Validate data against rules, with every built-in rule pre-registered.

6 methods
get_errors(self) -> Dict[str, List[str]]

Return the errors from the most recent :meth:`validate` call.

get_errors_flat(self) -> List[str]

Return every error message as a flat list, unkeyed by field.

is_valid(self, data: Dict[str, Any], rules: Dict[str, Union[str, List[Union[str, nitro_validator.core.rule.NitroValidationRule]]]], messages: Optional[Dict[str, Union[str, Dict[str, str]]]] = None) -> bool

Return ``True`` if ``data`` satisfies ``rules``, without raising.

make(data: Dict[str, Any], rules: Dict[str, Union[str, List[Union[str, nitro_validator.core.rule.NitroValidationRule]]]], messages: Optional[Dict[str, Union[str, Dict[str, str]]]] = None, registry: Optional[nitro_validato...

Construct a validator and run :meth:`validate` in one call.

register_rule(self, rule_class: type, name: Optional[str] = None) -> 'NitroValidator'

Register a custom rule class on this validator's registry.

validate(self, data: Dict[str, Any], rules: Dict[str, Union[str, List[Union[str, nitro_validator.core.rule.NitroValidationRule]]]], messages: Optional[Dict[str, Union[str, Dict[str, str]]]] = None) -> Dict[str, Any]

Run every rule for every field and return the validated data.

Validator#

Validator(registry: 'NitroRuleRegistry' = None)

Validate data against rules, with every built-in rule pre-registered.

6 methods
get_errors(self) -> Dict[str, List[str]]

Return the errors from the most recent :meth:`validate` call.

get_errors_flat(self) -> List[str]

Return every error message as a flat list, unkeyed by field.

is_valid(self, data: Dict[str, Any], rules: Dict[str, Union[str, List[Union[str, nitro_validator.core.rule.NitroValidationRule]]]], messages: Optional[Dict[str, Union[str, Dict[str, str]]]] = None) -> bool

Return ``True`` if ``data`` satisfies ``rules``, without raising.

make(data: Dict[str, Any], rules: Dict[str, Union[str, List[Union[str, nitro_validator.core.rule.NitroValidationRule]]]], messages: Optional[Dict[str, Union[str, Dict[str, str]]]] = None, registry: Optional[nitro_validato...

Construct a validator and run :meth:`validate` in one call.

register_rule(self, rule_class: type, name: Optional[str] = None) -> 'NitroValidator'

Register a custom rule class on this validator's registry.

validate(self, data: Dict[str, Any], rules: Dict[str, Union[str, List[Union[str, nitro_validator.core.rule.NitroValidationRule]]]], messages: Optional[Dict[str, Union[str, Dict[str, str]]]] = None) -> Dict[str, Any]

Run every rule for every field and return the validated data.

Rule base

NitroValidationRule#

NitroValidationRule(*args: Any, **kwargs: Any)

Base class for every validation rule in nitro-validator.

2 methods
get_message(self, field: str) -> str

Return the formatted error message for a failing field.

validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

Rule#

Rule(*args: Any, **kwargs: Any)

Base class for every validation rule in nitro-validator.

2 methods
get_message(self, field: str) -> str

Return the formatted error message for a failing field.

validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

Rule registry

NitroRuleRegistry#

NitroRuleRegistry() -> None

Store and look up validation rule classes by name.

6 methods
all(self) -> Dict[str, Type[nitro_validator.core.rule.NitroValidationRule]]

Return a shallow copy of the name-to-class mapping.

clear(self) -> None

Remove every registered rule. Useful for building a registry from scratch.

get(self, name: str) -> Type[nitro_validator.core.rule.NitroValidationRule]

Return the rule class registered under ``name``.

has(self, name: str) -> bool

Return ``True`` if a rule is registered under ``name``.

register(self, rule_class: Type[nitro_validator.core.rule.NitroValidationRule], name: Optional[str] = None) -> None

Register a rule class under its ``name`` attribute or an override.

unregister(self, name: str) -> None

Remove a rule from the registry. No-op if it is not registered.

RuleRegistry#

RuleRegistry() -> None

Store and look up validation rule classes by name.

6 methods
all(self) -> Dict[str, Type[nitro_validator.core.rule.NitroValidationRule]]

Return a shallow copy of the name-to-class mapping.

clear(self) -> None

Remove every registered rule. Useful for building a registry from scratch.

get(self, name: str) -> Type[nitro_validator.core.rule.NitroValidationRule]

Return the rule class registered under ``name``.

has(self, name: str) -> bool

Return ``True`` if a rule is registered under ``name``.

register(self, rule_class: Type[nitro_validator.core.rule.NitroValidationRule], name: Optional[str] = None) -> None

Register a rule class under its ``name`` attribute or an override.

unregister(self, name: str) -> None

Remove a rule from the registry. No-op if it is not registered.

Exceptions

NitroValidationError#

NitroValidationError(errors: Dict[str, List[str]])

Raise when one or more fields fail validation.

NitroValidatorException#

Base exception for every error raised by nitro-validator.

NitroRuleNotFoundError#

Raise when a rule name is referenced but has not been registered.

NitroInvalidRuleError#

Raise when a rule class is malformed or fails registration checks.

ValidationError#

ValidationError(errors: Dict[str, List[str]])

Raise when one or more fields fail validation.

ValidatorException#

Base exception for every error raised by nitro-validator.

RuleNotFoundError#

Raise when a rule name is referenced but has not been registered.

InvalidRuleError#

Raise when a rule class is malformed or fails registration checks.

Built-in rules

RequiredRule#

RequiredRule(*args: Any, **kwargs: Any)

Validate that a field is present and not empty.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

OptionalRule#

OptionalRule(*args: Any, **kwargs: Any)

Mark a field as optional (always passes).

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

AlphaRule#

AlphaRule(*args: Any, **kwargs: Any)

Validate that a field contains only alphabetic characters.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

AlphanumericRule#

AlphanumericRule(*args: Any, **kwargs: Any)

Validate that a field contains only alphanumeric characters.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

EmailRule#

EmailRule(*args: Any, **kwargs: Any)

Validate that a field is a valid email address.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

UrlRule#

UrlRule(*args: Any, **kwargs: Any)

Validate that a field is a valid URL.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

RegexRule#

RegexRule(*args: Any, **kwargs: Any)

Validate that a field matches a regular expression.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

LowercaseRule#

LowercaseRule(*args: Any, **kwargs: Any)

Validate that a field contains only lowercase characters.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

UppercaseRule#

UppercaseRule(*args: Any, **kwargs: Any)

Validate that a field contains only uppercase characters.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

AlphaDashRule#

AlphaDashRule(*args: Any, **kwargs: Any)

Validate that a field contains only letters, numbers, dashes, and underscores.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

StartsWithRule#

StartsWithRule(*args: Any, **kwargs: Any)

Validate that a field starts with a given substring.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

EndsWithRule#

EndsWithRule(*args: Any, **kwargs: Any)

Validate that a field ends with a given substring.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

ContainsRule#

ContainsRule(*args: Any, **kwargs: Any)

Validate that a field contains a given substring.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

UuidRule#

UuidRule(*args: Any, **kwargs: Any)

Validate that a field is a valid UUID.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

IpRule#

IpRule(*args: Any, **kwargs: Any)

Validate that a field is a valid IP address (v4 or v6).

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

Ipv4Rule#

Ipv4Rule(*args: Any, **kwargs: Any)

Validate that a field is a valid IPv4 address.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

Ipv6Rule#

Ipv6Rule(*args: Any, **kwargs: Any)

Validate that a field is a valid IPv6 address.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

JsonRule#

JsonRule(*args: Any, **kwargs: Any)

Validate that a field is a valid JSON string.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

SlugRule#

SlugRule(*args: Any, **kwargs: Any)

Validate that a field is a valid URL slug.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

AsciiRule#

AsciiRule(*args: Any, **kwargs: Any)

Validate that a field contains only ASCII characters.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

Base64Rule#

Base64Rule(*args: Any, **kwargs: Any)

Validate that a field is valid base64 encoding.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

HexColorRule#

HexColorRule(*args: Any, **kwargs: Any)

Validate that a field is a valid hex color code.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

CreditCardRule#

CreditCardRule(*args: Any, **kwargs: Any)

Validate that a field is a valid credit card number using Luhn algorithm.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

MacAddressRule#

MacAddressRule(*args: Any, **kwargs: Any)

Validate that a field is a valid MAC address.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

TimezoneRule#

TimezoneRule(*args: Any, **kwargs: Any)

Validate that a field is a valid timezone identifier.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

LocaleRule#

LocaleRule(*args: Any, **kwargs: Any)

Validate that a field is a valid locale code.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

NumericRule#

NumericRule(*args: Any, **kwargs: Any)

Validate that a field is numeric.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

IntegerRule#

IntegerRule(*args: Any, **kwargs: Any)

Validate that a field is an integer.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

MinRule#

MinRule(*args: Any, **kwargs: Any)

Validate that a field has a minimum value or length.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

MaxRule#

MaxRule(*args: Any, **kwargs: Any)

Validate that a field has a maximum value or length.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

BetweenRule#

BetweenRule(*args: Any, **kwargs: Any)

Validate that a field is between two values.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

PositiveRule#

PositiveRule(*args: Any, **kwargs: Any)

Validate that a field is a positive number.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

NegativeRule#

NegativeRule(*args: Any, **kwargs: Any)

Validate that a field is a negative number.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

DivisibleByRule#

DivisibleByRule(*args: Any, **kwargs: Any)

Validate that a field is divisible by a given number.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

SameRule#

SameRule(*args: Any, **kwargs: Any)

Validate that a field matches another field.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

DifferentRule#

DifferentRule(*args: Any, **kwargs: Any)

Validate that a field is different from another field.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

InRule#

InRule(*args: Any, **kwargs: Any)

Validate that a field is in a list of values.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

NotInRule#

NotInRule(*args: Any, **kwargs: Any)

Validate that a field is not in a list of values.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

BooleanRule#

BooleanRule(*args: Any, **kwargs: Any)

Validate that a field is a boolean value.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

DateRule#

DateRule(*args: Any, **kwargs: Any)

Validate that a field is a valid date.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

BeforeRule#

BeforeRule(*args: Any, **kwargs: Any)

Validate that a date field is before a given date.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

AfterRule#

AfterRule(*args: Any, **kwargs: Any)

Validate that a date field is after a given date.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

DateEqualsRule#

DateEqualsRule(*args: Any, **kwargs: Any)

Validate that a date field equals a given date.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

DateFormatRule#

DateFormatRule(*args: Any, **kwargs: Any)

Validate that a date field matches a specific format.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

ConfirmedRule#

ConfirmedRule(*args: Any, **kwargs: Any)

Validate that a field matches its confirmation field (field_confirmation).

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

AcceptedRule#

AcceptedRule(*args: Any, **kwargs: Any)

Validate that a field has been accepted (yes, true, 1, on).

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

DeclinedRule#

DeclinedRule(*args: Any, **kwargs: Any)

Validate that a field has been declined (no, false, 0, off).

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

LengthRule#

LengthRule(*args: Any, **kwargs: Any)

Validate that a field has an exact length.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

ArrayRule#

ArrayRule(*args: Any, **kwargs: Any)

Validate that a field is an array/list.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

SizeRule#

SizeRule(*args: Any, **kwargs: Any)

Validate that a field has an exact size (length/size/value).

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

DistinctRule#

DistinctRule(*args: Any, **kwargs: Any)

Validate that an array contains only unique values.

1 methods
validate(self, field: str, value: Any, data: dict) -> bool

Return ``True`` if ``value`` passes this rule, otherwise ``False``.

register_builtin_rules#

register_builtin_rules(registry: nitro_validator.core.rule_registry.NitroRuleRegistry) -> None

Register every built-in validation rule onto ``registry``.