Search


Search something to see results

between

Type Parameters

  • T extends {}

Parameters

  • min: T
  • max: T
  • reason: string = ...

Returns Object

import * as x from 'unhoax'

// works with dates
declare const today: Date
declare const nextMonth: Date
const refineInCurrentMonth = x.between(today, nextMonth, 'In current month')
const dateInCurrentMonth = refineInCurrentMonth(x.date)

// works with numbers
const refineAsStarRating = x.between(0, 5, 'StarRating')
const starRating = refineAsStarRating(x.number)

// or, using pipe
import pipe from 'just-pipe'

const starRating = pipe(
x.number,
x.between(0, 5, 'StarRating'),
) // Schema<number>