Overview
Scriptorium.Nib is the assertion layer for the Scriptorium family.
It works with any F# framework — or directly in application code.
Installation
Section titled “Installation”dotnet add package Scriptorium.NibAll assertions follows a consistent pattern:
- Start with
assertThat - Pass subject to validate
- Chain of assertions
Basic assertions
Section titled “Basic assertions”open Scriptorium.Nib.Assertion
assertThat 42 (isEqualTo 42)assertThat "hello" (isNotEqualTo "world")assertThat true isTrueCompositions
Section titled “Compositions”Assertions compose with >>
assertThat 42 (isGreaterThan 0 >> isLessThan 100 >> isNotEqualTo 99)Every assertion in the chain runs — failures are collected and reported together rather than stopping on the first one.
Nested assertions
Section titled “Nested assertions”Use inside and tag to drill into records and label failures:
assertThat { Name = "" Age = 15 } (inside _.Name (tag "name" >> isNotEqualTo "") >> inside _.Age (tag "age" >> isGreaterOrEqual 18))
// Throws:// [name] given "" should not be equal to ""// [age] given 15 should be greater than or equal to 18Collections, options, and results have dedicated assertions:
assertThat [ 1 2 3 ] (isNotEmpty >> hasSize 3 >> contain 2)
assertThat (Some "alice") (Option.value >> isNotEqualTo "")
assertThat (Ok 42: Result<int, string>) (Result.okValue >> isGreaterThan 0)