Skip to main content
Wrapper class for raw text entered into TextParameter widgets. It is returned by methods such as TextParameter.get_entered_text() so that the text cannot be accidentally treated as a plain string (for example, when building SQL). Instead of converting a TextValue directly to a string, you transform it using helper methods or pass it to APIs such as ContextArgs.set_placeholder, which safely unwrap the underlying text. Instances of TextValue are created by Squirrels and returned from parameter methods; you should not instantiate this class directly in your project code. If TextValue is needed for type annotation, it can be imported from the squirrels.types or squirrels module.

Methods

apply()

Transforms the entered text using a function that takes a string and returns a string, and returns a new TextValue.
TextValue
A new TextValue with the transformed text.
If the function does not return a string, a configuration error is raised.

apply_percent_wrap()

Returns a new TextValue with percent signs added before and after the entered text (for example, for use in SQL LIKE patterns).
TextValue
A new TextValue with percent signs wrapping the text.

apply_as_bool()

Transforms the entered text with a function that takes a string and returns a boolean.
bool
The boolean result from the input function.
If the function does not return a boolean, a configuration error is raised.

apply_as_number()

Transforms the entered text with a function that takes a string and returns a number.
int | float
The numeric result from the input function.
If the function does not return a number, a configuration error is raised.

apply_as_datetime()

Transforms the entered text with a function that takes a string and returns a datetime object.
datetime
The datetime result from the input function.
If the function does not return a datetime, a configuration error is raised.

Examples

The TextValue class is primarily used as a type hint in pyconfigs/context.py. You receive TextValue instances from methods like TextParameter.get_entered_text(), then transform them using the provided methods before passing to APIs that safely handle the text.

Using TextValue as a type hint in context.py

Transforming text

Converting text to other types