{"id":16720392,"url":"https://github.com/tomokimiyauci/assertion","last_synced_at":"2025-03-15T11:41:28.950Z","repository":{"id":57885818,"uuid":"528862804","full_name":"TomokiMiyauci/assertion","owner":"TomokiMiyauci","description":"Assertion collection for JavaScript data","archived":false,"fork":false,"pushed_at":"2023-04-21T03:09:47.000Z","size":77,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-10T14:58:27.934Z","etag":null,"topics":["assert","assertion","asserts","check","validate","validation"],"latest_commit_sha":null,"homepage":"https://deno.land/x/assertion","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomokiMiyauci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-25T13:26:47.000Z","updated_at":"2023-04-21T03:07:26.000Z","dependencies_parsed_at":"2022-08-26T19:20:20.119Z","dependency_job_id":null,"html_url":"https://github.com/TomokiMiyauci/assertion","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fassertion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fassertion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fassertion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fassertion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomokiMiyauci","download_url":"https://codeload.github.com/TomokiMiyauci/assertion/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725527,"owners_count":20337666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assert","assertion","asserts","check","validate","validation"],"created_at":"2024-10-12T22:06:58.594Z","updated_at":"2025-03-15T11:41:28.926Z","avatar_url":"https://github.com/TomokiMiyauci.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# assertion\n\n[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/assertion)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/TomokiMiyauci/assertion)](https://github.com/TomokiMiyauci/assertion/releases)\n[![codecov](https://codecov.io/github/TomokiMiyauci/assertion/branch/main/graph/badge.svg)](https://codecov.io/gh/TomokiMiyauci/assertion)\n[![GitHub](https://img.shields.io/github/license/TomokiMiyauci/assertion)](https://github.com/TomokiMiyauci/assertion/blob/main/LICENSE)\n\n[![test](https://github.com/TomokiMiyauci/assertion/actions/workflows/test.yaml/badge.svg)](https://github.com/TomokiMiyauci/assertion/actions/workflows/test.yaml)\n[![NPM](https://nodei.co/npm/@miyauci/assertion.png?mini=true)](https://nodei.co/npm/@miyauci/assertion/)\n\nAssertion collection for JavaScript data.\n\n## Module structure and capability\n\nModule can be divided into two categories.\n\n- [Top-type module](#top-type-module)\n- [Sub-type module](#sub-type-module)\n\n### Top-type module\n\nTop-type module can accept any JavaScript data. In other words, it accepts the\n`unknown` type.\n\nThe module directly under namespace is it.\n\n### Sub-type module\n\nSub-type modules are modules that perform type-dependent operations. It can use\ntype-specific methods and compare values.\n\nFor example, the module under `number` is a sub-type module that takes a\n`number` type as an argument.\n\n## Common\n\nAll function signatures have an `asserts` specifier.\n\nAll modules throw an error if the assert fails. And the errors are fully\ncustomizable.\n\n### Error message\n\nNo opinion on error message. Nothing by default.\n\nYou can give message.\n\n```ts\nimport { assertNumber } from \"https://deno.land/x/assertion@$VERSION/assert_number.ts\";\n\ndeclare const input: unknown;\n\nassertNumber(input, `must be number`);\n```\n\n### Error constructor\n\nNo opinion on error constructor.\n\nBy default, use `Error` constructor.\n\nTo throw `RangeError` instead, do the following.\n\n```ts\nimport { assertNonNegativeInteger } from \"https://deno.land/x/assertion@$VERSION/number/assert_non_negative_integer.ts\";\n\ndeclare const input: number;\n\nassertNonNegativeInteger(input, `must be non-negative integer`, RangeError);\n```\n\n## assertArray\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_array.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_array.ts)\n\nAssert the input is array.\n\n```ts\nimport { assertArray } from \"https://deno.land/x/assertion@$VERSION/assert_array.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertArray([]));\nassertThrows(() =\u003e assertArray({}));\n```\n\n## assertAsyncIterable\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_async_iterable.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_async_iterable.ts)\n\nAssert the input is `AsyncIterable`.\n\n```ts\nimport { assertAsyncIterable } from \"https://deno.land/x/assertion@$VERSION/assert_async_iterable.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(\n  assertAsyncIterable({\n    async *[Symbol.asyncIterator]() {\n      yield \"hello\";\n    },\n  }),\n);\nassertThrows(() =\u003e assertAsyncIterable(() =\u003e {}));\n```\n\n## assertBigint\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_bigint.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_bigint.ts)\n\nAssert the input is `bigint`.\n\n```ts\nimport { assertBigint } from \"https://deno.land/x/assertion@$VERSION/assert_bigint.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertBigint(1000n));\nassertThrows(() =\u003e assertBigint(undefined));\n```\n\n## assertBoolean\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_boolean.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_boolean.ts)\n\nAssert the input is `boolean`.\n\n```ts\nimport { assertBoolean } from \"https://deno.land/x/assertion@$VERSION/assert_boolean.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertBoolean(true));\nassertThrows(() =\u003e assertBoolean(null));\n```\n\n## assertDate\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_date.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_date.ts)\n\nAssert the input is `Date`.\n\n```ts\nimport { assertDate } from \"https://deno.land/x/assertion@$VERSION/assert_date.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertDate(new Date()));\nassertThrows(() =\u003e assertDate({}));\n```\n\n## assertError\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_error.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_error.ts)\n\nAssert the input is `Error`.\n\n```ts\nimport { assertError } from \"https://deno.land/x/assertion@$VERSION/assert_error.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertError(Error()));\nassertFalse(assertError(new SyntaxError()));\nassertThrows(() =\u003e assertError(new Date()));\n```\n\n## assertFunction\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_function.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_function.ts)\n\nAssert the input is `Function`.\n\n```ts\nimport { assertFunction } from \"https://deno.land/x/assertion@$VERSION/assert_function.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertFunction(() =\u003e {}));\nassertThrows(() =\u003e assertFunction({}));\n```\n\n## assertIterable\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_iterable.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_iterable.ts)\n\nAssert the input is `Iterable`.\n\n```ts\nimport { assertIterable } from \"https://deno.land/x/assertion@$VERSION/assert_iterable.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertIterable(\"\"));\nassertThrows(() =\u003e assertIterable({}));\n```\n\n## assertNonNullable\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_non_nullable.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_non_nullable.ts)\n\nAssert the input is not `null` or `undefined`.\n\n```ts\nimport { assertNonNullable } from \"https://deno.land/x/assertion@$VERSION/assert_non_nullable.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertNonNullable(\"\"));\nassertThrows(() =\u003e assertNonNullable(null));\nassertThrows(() =\u003e assertNonNullable(undefined));\n```\n\n## assertNull\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_null.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_null.ts)\n\nAssert the input is `null`.\n\n```ts\nimport { assertNull } from \"https://deno.land/x/assertion@$VERSION/assert_null.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertNull(null));\nassertThrows(() =\u003e assertNull(undefined));\n```\n\n## assertNullable\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_nullable.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_nullable.ts)\n\nAssert the input is `null` or `undefined`.\n\n```ts\nimport { assertNullable } from \"https://deno.land/x/assertion@$VERSION/assert_nullable.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertNullable(null));\nassertFalse(assertNullable(undefined));\nassertThrows(() =\u003e assertNullable({}));\n```\n\n## assertNumber\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_number.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_number.ts)\n\nAssert the input is `number`.\n\n```ts\nimport { assertNumber } from \"https://deno.land/x/assertion@$VERSION/assert_number.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertNumber(1000));\nassertThrows(() =\u003e assertNumber(\"hello world\"));\n```\n\n## assertObject\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_object.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_object.ts)\n\nAssert the input is `object`.\n\n```ts\nimport { assertObject } from \"https://deno.land/x/assertion@$VERSION/assert_object.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertObject({}));\nassertThrows(() =\u003e assertObject(null));\n```\n\n## assertPrimitive\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_primitive.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_primitive.ts)\n\nAssert the input is `Primitive`.\n\n```ts\nimport { assertPrimitive } from \"https://deno.land/x/assertion@$VERSION/assert_primitive.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertPrimitive(true));\nassertThrows(() =\u003e assertPrimitive({}));\n```\n\n```ts\ntype Primitive =\n  | number\n  | string\n  | boolean\n  | bigint\n  | undefined\n  | null\n  | symbol;\n```\n\n## assertPromise\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_promise.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_promise.ts)\n\nAssert the input is `Promise`.\n\n```ts\nimport { assertPromise } from \"https://deno.land/x/assertion@$VERSION/assert_promise.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertPromise(Promise.resolve()));\nassertThrows(() =\u003e assertPromise({}));\n```\n\n## assertRegExp\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_reg_exp.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_reg_exp.ts)\n\nAssert the input is `RegExp`.\n\n```ts\nimport { assertRegExp } from \"https://deno.land/x/assertion@$VERSION/assert_reg_exp.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertRegExp(new RegExp(\"\")));\nassertThrows(() =\u003e assertRegExp({}));\n```\n\n## assertString\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_string.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_string.ts)\n\nAssert the input is `string`.\n\n```ts\nimport { assertString } from \"https://deno.land/x/assertion@$VERSION/assert_string.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertString(\"hello world\"));\nassertThrows(() =\u003e assertString(1000));\n```\n\n## assertSymbol\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_symbol.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_symbol.ts)\n\nAssert the input is `symbol`.\n\n```ts\nimport { assertSymbol } from \"https://deno.land/x/assertion@$VERSION/assert_symbol.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertSymbol(Symbol(\"symbol\")));\nassertThrows(() =\u003e assertSymbol(null));\n```\n\n## assertUndefined\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/assert_undefined.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fassert_undefined.ts)\n\nAssert the input is `undefined`.\n\n```ts\nimport { assertUndefined } from \"https://deno.land/x/assertion@$VERSION/assert_undefined.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertUndefined(undefined));\nassertThrows(() =\u003e assertUndefined(null));\n```\n\n## Number subtypes\n\nAssert a subtype of `number`. All assertion functions must satisfy ⊂ `number`.\n\n### assertEven\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/number/assert_even.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fnumber%2Fassert_even.ts)\n\nAssert the input is even.\n\n```ts\nimport { assertEven } from \"https://deno.land/x/assertion@$VERSION/number/assert_even.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertEven(0));\nassertThrows(() =\u003e assertEven(1));\n```\n\n### assertNegativeNumber\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/number/assert_negative_number.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fnumber%2Fassert_negative_number.ts)\n\nAssert the input is negative number.\n\n```ts\nimport { assertNegativeNumber } from \"https://deno.land/x/assertion@$VERSION/number/assert_negative_number.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertNegativeNumber(-1));\nassertThrows(() =\u003e assertNegativeNumber(0));\n```\n\n### assertNonNegativeInteger\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/number/assert_non_negative_number.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fnumber%2Fassert_non_negative_number.ts)\n\nAssert the input is non-negative integer.\n\n```ts\nimport { assertNonNegativeInteger } from \"https://deno.land/x/assertion@$VERSION/number/assert_non_negative_integer.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertNonNegativeInteger(0));\nassertFalse(assertNonNegativeInteger(1));\nassertThrows(() =\u003e assertNonNegativeInteger(-1));\n```\n\n### assertNonNegativeNumber\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/number/assert_non_negative_integer.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fnumber%2Fassert_non_negative_integer.ts)\n\nAssert the input is non-negative number. Non-negative number means greater than\nor equal to zero.\n\n```ts\nimport { assertNonNegativeNumber } from \"https://deno.land/x/assertion@$VERSION/number/assert_non_negative_number.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertNonNegativeNumber(0));\nassertFalse(assertNonNegativeNumber(1.1));\nassertThrows(() =\u003e assertNonNegativeNumber(-1));\n```\n\n### assertNonPositiveNumber\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/number/assert_non_positive_number.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fnumber%2Fassert_non_positive_number.ts)\n\nAssert the input is non-positive number. Non-positive number means less than or\nequal to zero.\n\n```ts\nimport { assertNonPositiveNumber } from \"https://deno.land/x/assertion@$VERSION/number/assert_non_positive_number.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertNonPositiveNumber(0));\nassertFalse(assertNonPositiveNumber(-1));\nassertThrows(() =\u003e assertNonPositiveNumber(1));\n```\n\n### assertOdd\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/number/assert_odd.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fnumber%2Fassert_odd.ts)\n\nAssert the input is odd.\n\n```ts\nimport { assertOdd } from \"https://deno.land/x/assertion@$VERSION/number/assert_odd.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertOdd(1));\nassertThrows(() =\u003e assertOdd(0));\n```\n\n### assertPositiveNumber\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/number/assert_positive_number.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fnumber%2Fassert_positive_number.ts)\n\nAssert the input is positive number.\n\n```ts\nimport { assertPositiveNumber } from \"https://deno.land/x/assertion@$VERSION/number/assert_positive_number.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertPositiveNumber(1));\nassertThrows(() =\u003e assertPositiveNumber(0));\n```\n\n### assertUnitInterval\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/number/assert_unit_interval.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fnumber%2Fassert_unit_interval.ts)\n\nAssert the input is unit interval. The unit interval means to the interval\nbetween 0 and 1 on the real number line.\n\n```ts\nimport { assertUnitInterval } from \"https://deno.land/x/assertion@$VERSION/number/assert_unit_interval.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertUnitInterval(0));\nassertFalse(assertUnitInterval(1.0));\nassertThrows(() =\u003e assertUnitInterval(-1));\n```\n\n## Iterable subtypes\n\nAssert a subtype of `Iterable`. All assertion functions must satisfy ⊂\n`Iterable\u003cunknown\u003e`.\n\n### assertEmpty\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/iterable/assert_empty.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fiterable%2Fassert_empty.ts)\n\nAssert the input is empty.\n\n```ts\nimport { assertEmpty } from \"https://deno.land/x/assertion@$VERSION/iterable/assert_empty.ts\";\nimport { assertFalse } from \"https://deno.land/std/testing/asserts.ts\";\n\nassertFalse(assertEmpty(\"\"));\nassertFalse(assertEmpty([]));\nassertFalse(assertEmpty(new Set()));\n```\n\nstring:\n\nIf the input is a string, it has a `\"\"` assertion.\n\narray:\n\nIf the input is a array, it has a `[]` assertion.\n\n### assertNotEmpty\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/iterable/assert_non_empty.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fiterable%2Fassert_non_empty.ts)\n\nAssert the input is not empty.\n\n```ts\nimport { assertNotEmpty } from \"https://deno.land/x/assertion@$VERSION/iterable/assert_not_empty.ts\";\nimport { assertFalse } from \"https://deno.land/std/testing/asserts.ts\";\n\nassertFalse(assertNotEmpty(\"a\"));\nassertFalse(assertNotEmpty([0, 1]));\n```\n\narray:\n\nIf the input is a `T[]`, it has a `[T, ...T[]]` assertion.\n\n### assertSingle\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/iterable/assert_single.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fiterable%2Fassert_single.ts)\n\nAssert the input is single element.\n\n```ts\nimport { assertSingle } from \"https://deno.land/x/assertion@$VERSION/iterable/assert_single.ts\";\nimport {\n  assert,\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\n\nassertFalse(assertSingle(\"a\"));\nassertFalse(assertSingle([0]));\nassertThrows(() =\u003e assertSingle([0, 1, 2]));\n```\n\narray:\n\nIf the input is a `T[]`, it has a `[T]` assertion.\n\n## Date subtypes\n\nValidates a subtype of `Date`. All validate functions must satisfy ⊂ `Date`.\n\n### assertValidDate\n\n[![badge](https://deno.bundlejs.com/?q=https://deno.land/x/assertion/date/assert_valid_date.ts\u0026badge=)](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fassertion%2Fdate%2Fassert_valid_date.ts)\n\nAssert the input is valid `Date`.\n\n```ts\nimport { assertValidDate } from \"https://deno.land/x/assertion@$VERSION/date/assert_valid_date.ts\";\nimport {\n  assertFalse,\n  assertThrows,\n} from \"https://deno.land/std/testing/asserts.ts\";\nassertFalse(assertValidDate(new Date(\"2000/1/1\")));\nassertThrows(() =\u003e assertValidDate(new Date(\"invalid\")));\n```\n\n## Bundle size\n\nBundle size is not exact. It is only a guide.\n\nUsually, the actual bundle size is **smaller** than the indicated value.\n\n## Where is mod?\n\nThere is no single entry point such as `mod`.\n\nThis prevents the inclusion of many unnecessary modules.\n\n## License\n\nCopyright © 2023-present [Tomoki Miyauchi](https://github.com/TomokiMiyauci).\n\nReleased under the [MIT](./LICENSE) license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomokimiyauci%2Fassertion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomokimiyauci%2Fassertion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomokimiyauci%2Fassertion/lists"}