Skip to main content
Module

x/typestruct/mod.ts>nonnegative

Composable and checkable JavaScript (and TypeScript) data structure
Latest
function nonnegative
import { nonnegative } from "https://deno.land/x/typestruct@1.0.0-beta.5/mod.ts";

Create negative value struct. Ensure the input is non-negative number. Non-negative number means greater than or equal to zero.

Examples

Example 1

import {
  is,
  nonnegative,
} from "https://deno.land/x/typestruct@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std@$VERSION/testing/asserts.ts";

assertEquals(is(nonnegative(), 0), true);
assertEquals(is(nonnegative(), 1), true);
assertEquals(is(nonnegative(), -1), false);

Parameters

optional
message: string

Custom issue message.