Skip to content
CCPEDIAby Unity Nodes
App Development

Did DA considered to add a function such as isNonEmpty

4 posts113 views1 likesLast activity Oct 2024

  1. cohen.avrahamOP

    G-d willing

    Hello,
    Would you consider adding another function to the DA.Text lib a function such as:

    isNonEmptyText: Text -> Bool
    isNonEmptyText text = (not . Text.isEmpty) text
    

    This is something that I do quite often, and instead of repeating this code in every place I use it, or placing it in a separated package, this way all my packages will use it, sounds a bit too much.

    Thanks,

  2. Johan_Sjodin

    Hi @cohen.avraham,

    you could as well define it as

        isNonEmptyText : Text -> Bool
        isNonEmptyText = (/=) ""
    

    or simply use text /= "" instead of isNonEmptyText text.

    Hope that helps,
    Johan

  3. cohen.avraham

    Thanks @Johan_Sjodin for your reply.
    I am aware of this, but I was curious about a dedicated function for it like there is for isEmpty
    Anyway, thanks again

  4. WallaceKelly 1

    It is open source. :slight_smile: Here is an implementation:

    github.com/digital-asset/daml

    Add DA.Text.isNotEmpty function

    digital-asset:main ← digital-asset:add-da-text-isnotempty
    opened 06:58PM - 10 Oct 24 UTC

    A `Text.isNotEmpty` function is needed frequently enough to warrant being added …