Skip to main content Link Menu Expand (external link) Document Search Copy Copied

NonEmptyString overview

Added in v0.4.5


Table of contents


NonEmptyStringBrand (interface)

Signature

export interface NonEmptyStringBrand {
  readonly NonEmptyString: unique symbol
}

Added in v0.4.5

NonEmptyStringC (interface)

Signature

export interface NonEmptyStringC extends t.Type<NonEmptyString, string, unknown> {}

Added in v0.4.5

NonEmptyString (type alias)

Signature

export type NonEmptyString = t.Branded<string, NonEmptyStringBrand>

Added in v0.4.5

NonEmptyString

A codec that succeeds if a string is not empty

Signature

export const NonEmptyString: NonEmptyStringC = ...

Example

import { NonEmptyString } from 'io-ts-types/lib/NonEmptyString'
import { right } from 'fp-ts/lib/Either'
import { PathReporter } from 'io-ts/lib/PathReporter'

assert.deepStrictEqual(NonEmptyString.decode('a'), right('a'))
assert.deepStrictEqual(PathReporter.report(NonEmptyString.decode('')), [
  'Invalid value "" supplied to : NonEmptyString'
])

Added in v0.4.5