Constraints:
Filter:
crucial-library/Guides (extension) | Libraries > crucial > Constraints

Constraints
ExtensionExtension

specify a condition or logical query, further filter and refine it

Constraints let you specify conditions in an OOP fashion. You can perform logical operations on the constraint object itself to further filter or refine your query.

c is now a constraint object that can be used to validate that an input is even, divisible by 4 and is not the number 8.

This can be used any place a function that returns true/false is required. eg. select, reject, every, any

It can be used in place of a function for SequenceableCollections, Streams and Patterns

The below example is expressed using only Constraint.

It could also be expressed this way

Constraints respond to

.not .or(aConstraint) .and(aConstraint) .xor(aConstraint) .reject(aConstraint) .select(aConstraint)

by returning a new compound constraint that expresses that logic.