A comprehensive collection of E2E validation utilities for testing
applications.
TestValidator provides type-safe validation functions for common testing
scenarios including condition checking, equality validation, error testing,
HTTP error validation, pagination testing, search functionality validation,
and sorting validation.
Most functions use direct parameter passing for simplicity, while some
maintain currying patterns for advanced composition. All provide detailed
error messages for debugging failed assertions.
Processing cost: Scalar assertions use constant bookkeeping; JSON assertions
traverse the expected structure, index compares the shared page prefix,
search scans the dataset once per sample and sort checks adjacent results.
External callbacks own their computation costs.
contracts/common.md#principled-implementation Each validator runs a check and throws an Error whose message begins with Bug on <title>, returning a promise only when its input is asynchronous, so the same function serves synchronous and asynchronous tests; the comparison helpers read values through their JSON form, which is the form an HTTP API delivers.
Evidence
contracts/common.md#clear-and-simple-design One function per assertion kind, sharing the JSON comparison (json_equal_to) and two small module helpers (is_promise and is_sorted), with the curried forms only where a request must be prepared once and run twice.
Evidence
contracts/common.md#prohibited-implementation-shortcuts Assertions compare the values they are given; none consults a fixture, an entity name, or an environment.
Evidence
contracts/common.md#meaningful-documentation The namespace prose lists the assertion families and the error message convention, with examples.
A comprehensive collection of E2E validation utilities for testing applications.
TestValidator provides type-safe validation functions for common testing scenarios including condition checking, equality validation, error testing, HTTP error validation, pagination testing, search functionality validation, and sorting validation.
Most functions use direct parameter passing for simplicity, while some maintain currying patterns for advanced composition. All provide detailed error messages for debugging failed assertions.
Processing cost: Scalar assertions use constant bookkeeping; JSON assertions traverse the expected structure, index compares the shared page prefix, search scans the dataset once per sample and sort checks adjacent results. External callbacks own their computation costs.
Author
Jeongho Nam - https://github.com/samchon
Example
Evidence
contracts/common.md#principled-implementation Each validator runs a check and throws an
Errorwhose message begins withBug on <title>, returning a promise only when its input is asynchronous, so the same function serves synchronous and asynchronous tests; the comparison helpers read values through their JSON form, which is the form an HTTP API delivers.Evidence
contracts/common.md#clear-and-simple-design One function per assertion kind, sharing the JSON comparison (
json_equal_to) and two small module helpers (is_promiseandis_sorted), with the curried forms only where a request must be prepared once and run twice.Evidence
contracts/common.md#prohibited-implementation-shortcuts Assertions compare the values they are given; none consults a fixture, an entity name, or an environment.
Evidence
contracts/common.md#meaningful-documentation The namespace prose lists the assertion families and the error message convention, with examples.