Skip to content

Provide some conditional helpers #21

Description

@nesk

We could provide some conditional helpers :

  • ifNotNull
  • ifInstanceOf

Instead of:

if (prop.unwrap() != null) prop { // this: Validatable<SomeClass?>
    constrain { it?.someBool == true }
}

we could write:

prop.ifNotNull { // this: Validatable<SomeClass>
    constrain { it.someBool }
}

We avoid calling unwrap, the receiver is automatically defined, and it's no longer nullable.

Some helpers unrelated to type casting could be useful too:

  • ifNotEmpty (CharSequence and iterables)
  • ifNotBlank
  • ifNotNullOrEmpty
  • ifNotNullOrBlank

Metadata

Metadata

Assignees

No one assigned

    Labels

    DSLAPI design and its DSLcoreThe core of the library is involvedenhancementNew feature or request

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions