Skip to content

boolean isValid(String data) would be useful in class Multibase #38

@vorburger

Description

@vorburger

I just added this to my Multihashes utility:

public static boolean isValid(String multihash) {
        try {
            Multihash.decode(multihash);
            return true;
        } catch (IllegalArgumentException e) {
            return false;
        }
    }

Because Base.lookup() throws an IllegalArgumentException, and decode() throws a UnsupportedOperationException, you currently as-is cannot really do it any better way.

But this is of course not ideal for performance. How about having a method like this in class Multibase here?

Would a PR for this be welcome here and get reviewed and merged?

@ianopolous @mk868

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions