Copied to clipboard

Flag this post as spam?

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


  • UPSB 9 posts 79 karma points
    Sep 17, 2019 @ 11:17
    UPSB
    0

    Custom validation for every property

    Is there a way to add additional validators to all properties, like every property can be made mandatory. I am trying to add a uniqueness validator, and combined uniqueness validator.

  • Shaishav Karnani from digitallymedia.com 330 posts 1536 karma points
    Sep 18, 2019 @ 11:45
    Shaishav Karnani from digitallymedia.com
    0

    Hi,

    You can add following validation only.

    Alternatively, you need to create your own property and can add more validation.

    I think best option for you is do the server-side validation for uniqueness. You can do it in Content Saving Event and if it is not validated then show Warning to user and stop saving node.

    Hope this help to solve the issue. If you need any further queries do let me know.

    enter image description here

    Cheers, Shaishav

  • UPSB 9 posts 79 karma points
    Sep 18, 2019 @ 12:03
    UPSB
    0

    Hi Shaishav,

    Most likely ill use combination of front end (as you suggested property validation). Here i also found couple of limitations as val-property-validator cant really take a promise and i didn't fond any way how to get content tree(in my case a part of a tree) without using services which return promise (but i kind of solved this problem).

    And sever side validation will be done with "Saving" event. But 8.13 ubraco version has a bug if you try to save content which hasn't been created and you use localization, you can cancel the saving but error is not showed and dialog for languages isn't closed. But if content was saved once when it seams to work normally.

    Still having ability to create global validators for properties would be a very nice feature.

    If i have the time i will submit a bug report (should i submit in git repository).

  • UPSB 9 posts 79 karma points
    Sep 20, 2019 @ 15:11
    UPSB
    0

    It seams that canceling a cancel-able save event still saves data. Does anything works in umbraco? Or do i need to do something extra apart of using CancelOperation method?

    I am using: ContentSavingEventArgs e

    e.CancelOperation(...)

  • Shaishav Karnani from digitallymedia.com 330 posts 1536 karma points
    Sep 21, 2019 @ 15:05
    Shaishav Karnani from digitallymedia.com
    0

    I havn't tested this feature as of now!

    Cheers, Shaishav

  • UPSB 9 posts 79 karma points
    Sep 23, 2019 @ 06:16
    UPSB
    0

    Did more testing, it cancels saving, but there is something wrong with cache as going back to a different content and then going back shows all the changed values as if content was saved. ctrl+f5 on that page also doesn't clear values to pre-saving state. Turning off umbraco and then turning it back on shows the pre-saving values.

    Seams there might be cache problems, it acts the same for custom properties and default properties.

  • UPSB 9 posts 79 karma points
    30 days ago
    UPSB
    0

    Is there a way to force for content cache reset in back-end or for front-end to respect that content save was canceled and use content cache state before the save?

Please Sign in or register to post replies

Write your reply to:

Draft