matyalatte / tuw

Tiny GUI wrapper for command-line tools
MIT License
31 stars 2 forks source link

Text Validation #24

Closed matyalatte closed 4 months ago

matyalatte commented 9 months ago

Related to https://github.com/matyalatte/tuw/issues/23.

Some options to show error dialogs when there are invalid strings in text boxes.

matyalatte commented 5 months ago

Validator was added at a4e1bb64bdac6ee7e8d0239df832dbd16bde3224 ~ 1acea935a95d2621db38ae2454ffdc84ee4a0e74.

The new options should be defined in the validator option.

"components": [
    {
        "type": "file",
        "label": "PNG or JPG", 
        "validator": {
            "not_empty": true,
            "exist": true
        }
    }
]

Each component can show an validation error message when clicking the execution button. Screenshot (97)

You can also override the error messages with *_error options. Screenshot (98)

"components": [
    {
        "type": "file",
        "label": "PNG or JPG", 
        "validator": {
            "not_empty": true,
            "not_empty_error": "Type something"
            "exist": true,
            "exist_error": "Custom error message!"
        }
    }
]
matyalatte commented 4 months ago

Close with v0.7.0 release.