Search


Search something to see results

date

date: Schema<Date, unknown> = ...

It can parse anything the Date constructor can take as single parameter.

If you need to accept Date only, use x.instanceOf(Date)

import * as x from 'unhoax'

const schema = x.date

// Date
x.date.parse(new Date()) // succeeds

// string
x.date.parse('2021-01-02T03:04:05.123Z') // succeeds
x.date.parse('2021-01-02') // succeeds

// number
x.date.parse(Date.now()) // succeeds