Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 724 Bytes

readme.md

File metadata and controls

28 lines (22 loc) · 724 Bytes

falseRule

This function uses the rulr.isFalse guard to check the input is false as shown in the example below. It should only throw rulr.InvalidFalseError. This rule is typically used alongside union and trueRule for validating HTTP responses that contain a boolean ok property.

import * as rulr from 'rulr'

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

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

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

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