Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful validation of fields with placeholders #1132

Closed
bjarnef opened this issue Dec 18, 2023 · 3 comments
Closed

Graceful validation of fields with placeholders #1132

bjarnef opened this issue Dec 18, 2023 · 3 comments
Labels
release/10.5.3 release/12.2.2 release/13.0.1 state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks type/bug

Comments

@bjarnef
Copy link

bjarnef commented Dec 18, 2023

I noticed on one our Umbraco Cloud project, a multi-site / multi-language solutions, that a contact form failed rendering on the German site, but not on other sites.

image

image

First I though it was because of the German characters in error messages like ü, ä and ö, but after further investigation I found it was due a syntax error in the error message.

image

I wonder if we could either have some regex validation here in case the validation message contains {0 or 0} and maybe even {{0}}?

or some graceful validation, when rendering the form. E.g. log the error message, but don't fail rendering the entire form.
It could eventually just fallback to default error message or just use the raw string, so it frontend one would just see Bitte überprüfen Sie 0} instead of the correct message Bitte überprüfen Sie {0} where {0} is replaced with the actual field name.

I think this is less critical as content editors sometimes make mistakes and often not familiar with {0} placeholder.

The description below "Mandatory Error Message" and "Invalid Error Message" can eventually mention this as well, because if one deleted it, it can be difficult to know it's an option to add.

Forms v12.1.2
Umbraco v12.2.0


This item has been added to our backlog AB#36127

@bjarnef bjarnef changed the title Greceful validation of fields with placeholders Graceful validation of fields with placeholders Dec 18, 2023
@bjarnef
Copy link
Author

bjarnef commented Dec 18, 2023

Maybe something like this: https://stackoverflow.com/a/36642556

public static class StringExtensions
{
    public static bool HasPlaceholder(this string s)
    {
        return Regex.IsMatch(s, "{\\d+}");
    }
}

But there is of course a chance one of the placeholders can be incorrect formatted. I haven't checked of Forms only use a single value as placeholder and if it is possible to extend added more placeholder values.

image

@AndyButland AndyButland added type/bug state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks labels Dec 18, 2023
@dtng95
Copy link

dtng95 commented Dec 29, 2023

Hi @bjarnef,
Thank you for reporting this issue.
A fix has been made and will be included in the next release/patch

@AndyButland
Copy link

We'll include a basic check for a valid format string, as expected for these validation messages, with the next round of patch releases for the versions indicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/10.5.3 release/12.2.2 release/13.0.1 state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks type/bug
Projects
None yet
Development

No branches or pull requests

3 participants