Skip to content

and

and<A, C>(second): <B>(first) => Refinement<A, B & C>

Defined in: Core/Refinement.ts:91

Intersects two refinements: the result narrows A to B & C, passing only when both refinements hold simultaneously.

Data-last — the first refinement is the data being piped.

A

C

Refinement<A, C>

<B>(first): Refinement<A, B & C>

B

Refinement<A, B>

Refinement<A, B & C>

const isString: Refinement<unknown, string> = Refinement.make(x => typeof x === "string");
const isNonEmpty: Refinement<unknown, { length: number }> =
  Refinement.make(x => (x as any).length > 0);

const isNonEmptyString = pipe(isString, Refinement.and(isNonEmpty));
isNonEmptyString("hi");  // true
isNonEmptyString("");    // false