Skip to content

Text Validation

Validate text input.

Validation Module

Text validation utilities.

This submodule provides utilities for validating text formats and content types.

Examples

from rite.text.validation import text_is_email, text_is_numeric text_is_email("user@example.com") True text_is_numeric("123") True

Modules

text_is_alpha

Text Is Alpha

Check if text is alphabetic.

Examples

from rite.text.validation import text_is_alpha text_is_alpha("Hello") True

Functions

text_is_alpha(text: str) -> bool

Check if text contains only alphabetic characters.

Parameters:

Name Type Description Default
text str

String to validate.

required

Returns:

Type Description
bool

True if alphabetic, False otherwise.

Examples:

>>> text_is_alpha("Hello")
True
>>> text_is_alpha("Hello123")
False
Notes

Uses str.isalpha() method.

text_is_alphanumeric

Text Is Alphanumeric

Check if text is alphanumeric.

Examples

from rite.text.validation import text_is_alphanumeric text_is_alphanumeric("Hello123") True

Functions

text_is_alphanumeric(text: str) -> bool

Check if text contains only alphanumeric characters.

Parameters:

Name Type Description Default
text str

String to validate.

required

Returns:

Type Description
bool

True if alphanumeric, False otherwise.

Examples:

>>> text_is_alphanumeric("Hello123")
True
>>> text_is_alphanumeric("Hello 123")
False
Notes

Uses str.isalnum() method.

text_is_email

Text Is Email

Validate email address format.

Examples

from rite.text.validation import text_is_email text_is_email("user@example.com") True

Functions

text_is_email(text: str) -> bool

Check if text is valid email format.

Parameters:

Name Type Description Default
text str

String to validate.

required

Returns:

Type Description
bool

True if valid email format, False otherwise.

Examples:

>>> text_is_email("[email protected]")
True
>>> text_is_email("invalid.email")
False
Notes

Basic email validation using regex. Not RFC-compliant, for simple checks only.

text_is_numeric

Text Is Numeric

Check if text is numeric.

Examples

from rite.text.validation import text_is_numeric text_is_numeric("123") True

Functions

text_is_numeric(text: str) -> bool

Check if text contains only numeric characters.

Parameters:

Name Type Description Default
text str

String to validate.

required

Returns:

Type Description
bool

True if numeric, False otherwise.

Examples:

>>> text_is_numeric("123")
True
>>> text_is_numeric("12.34")
False
>>> text_is_numeric("abc")
False
Notes

Uses str.isnumeric() method. Returns False for floats with decimals.

options: show_root_heading: true show_source: false heading_level: 2