Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dennis Adolfi 1072 posts 6378 karma points MVP 2x c-trib
    Apr 16, 2016 @ 07:32
    Dennis Adolfi
    0

    Custom validation for prevalue fields

    Hello Umbracians. I have a problem.

    Im creating a custom propertyeditor with a few prevalue fields. One of them is a number field that i need to be required. I´ve managed to add the validation type "Required" and it works just fine (the editor cannot be saved without a number value) but i want to show my custom errormessage. What do i add to get this?

    This is my prevalue field:

            fields: [
                            {
                                label: "Max number",
                                description: "Max number.",
                                key: "maxNumber",
                                view: "number",
                                validation: [
                                {
                                    type: "Required",
                                    errorMessage: "Custom message", <-- Did not work
                                    errorMsg: "Custom message", <-- Did not work
                                    message: "Custom message", <-- Did not work
                                }
                                ]
                            },
    

    All the above gives me this generic error message:

    enter image description here

    Hope anyone can help!

  • Dennis Adolfi 1072 posts 6378 karma points MVP 2x c-trib
    Apr 18, 2016 @ 07:37
    Dennis Adolfi
    0

    Great thinking Dennis, posting a thread on a weekend.

    I keep forgetting that other people have lives..

  • Peter Bersani 14 posts 34 karma points
    Jun 04, 2018 @ 18:59
    Peter Bersani
    0

    Ever figure this out? I am having the exact same problem.

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Jun 04, 2018 @ 20:36
    Jan Skovgaard
    0

    Hi Peter

    Could you perhaps share your current code on a Github gist for instance? it will make it a bit easier to understand the full context of your issue. I get that you need to be able to display a custom error message defined in the package.manifest but getting the full context will make it easier to test the code on a local instance of Umbraco and figure out if this might be a bug that needs to be addressed or if it's better and more desirable to make a workaround where you do the validation in the controller yourself by hooking into the notificationService for instance.

    Looking forward to hearing from you.

    /Jan

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies