Skip to content

MaskedInput ValueError Value does not match template #5493

Open
@JonathanPlasse

Description

@JonathanPlasse

Have you checked closed issues? https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed

Yes, no issue mentioned problems with MaskedInput validation.

Have you checked against the most recent version of Textual? https://pypi.org/search/?q=textual

Yes

Please give a brief but clear explanation of the issue. If you can, include a complete working example that demonstrates the bug. Check it can run without modifications.

  1. Run the app
uv run --script masked_input_value_error.py
  1. Press the key e or any other non digit.
  2. Watch the app crash with a ValueError.

masked_input_value_error.py

# /// script
# requires-python = ">=3.13"
# dependencies = [
#     "textual==1.0.0",
# ]
# ///
from textual.app import App, ComposeResult
from textual.widgets import MaskedInput


class BugApp(App[None]):
    def compose(self) -> ComposeResult:
        yield MaskedInput("9", "9")


app = BugApp()
app.run()

It will be helpful if you run the following command and paste the results:

textual diagnose

If you don't have the textual command on your path, you may have forgotten to install the textual-dev package.

Feel free to add screenshots and / or videos. These can be very helpful!

Screencast.from.2025-01-24.22-33-57.mp4

Image

Image

Textual Diagnostics

Versions

Name Value
Textual 1.0.0
Rich 13.9.4

Python

Name Value
Version 3.13.0
Implementation CPython
Compiler Clang 18.1.8
Executable /home/jonathan/.cache/uv/archive-v0/uhCuU97F8DMiIyfN6OiqV/bin/python

Operating System

Name Value
System Linux
Release 6.12.9-100.fc40.x86_64
Version #1 SMP PREEMPT_DYNAMIC Thu Jan 9 16:04:00 UTC 2025

Terminal

Name Value
Terminal Application vscode (1.96.4)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=142, height=23
legacy_windows False
min_width 1
max_width 142
is_terminal True
encoding utf-8
max_height 23
justify None
overflow None
no_wrap False
highlight None
markup None
height None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions