Search


Search something to see results

max

Type Parameters

  • T extends {}

Parameters

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

Returns Object

import * as x from 'unhoax'

// works with dates
const refineNowOrBefore = x.max(new Date(), 'now or before')
const dateNowOrBefore = refineNowOrBefore(x.date)

// works with numbers
const refineAsNegativeOrZero = x.max(0, 'Negative or zero')
const negativeOrZero = refineAsNegativeOrZero(x.number)

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

const negativeNumber = pipe(
x.number,
x.max(0, 'NegativeOrZero'),
) // Schema<number>