Skip to content

How to do either-or assertions? #450

Open
@hakanai

Description

@hakanai

I have a value where it can either be null, or if non-null it must match a pattern.

So I'd like to be able to do something like

assertThat(value).any(
    { a -> a.isNull() },
    { a -> isNotNull().matches(Regex("""some pattern""")) }
)

The existing code I'm converting from Java and AssertJ is using anyOf(Condition...) to do this.

I guess matchesPredicate is possible as a last resort, but it removes all potential for reusing existing assertions. :(

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions