Raxol.UI.Components.Input.TextInput.Validation (Raxol v0.4.0)

View Source

Handles input validation for the TextInput component. This includes length validation, pattern matching, and error message generation.

Summary

Functions

Validates the input value against the component's constraints. Returns a new state with any validation errors.

Validates a value's length against a maximum. Returns :ok if valid, {:error, reason} if invalid.

Validates a value against a pattern. Returns :ok if valid, {:error, reason} if invalid.

Checks if adding text would exceed the maximum length.

Functions

validate_input(state)

Validates the input value against the component's constraints. Returns a new state with any validation errors.

validate_length(value, max_length)

Validates a value's length against a maximum. Returns :ok if valid, {:error, reason} if invalid.

validate_pattern(value, pattern)

Validates a value against a pattern. Returns :ok if valid, {:error, reason} if invalid.

would_exceed_max_length?(state, char)

Checks if adding text would exceed the maximum length.