Skip to content

Latest commit

History

History
30 lines (23 loc) 路 580 Bytes

readme.md

File metadata and controls

30 lines (23 loc) 路 580 Bytes

boolean

Back to root readme.md

This function uses the rulr.isBoolean guard to check the input is a boolean as shown in the example below. It should only throw rulr.InvalidBooleanError.

import * as rulr from 'rulr'

const constrainToExample = rulr.object({
	required: {
		example: rulr.boolean,
	},
})

type Example = rulr.Static<typeof constrainToExample>
// {
//   example: boolean
// }

// Valid
const example1: Example = constrainToExample({
	example: true,
})

// Invalid
const example2: Example = constrainToExample({
	example: 1,
})