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

InputError overview

A module that implements an error that occurs upon receiving an unexpected input


Table of contents


Constructors

assertEmpty

Returns a right of input if input isnot the empty string. Otherwise, returns a left of an InputError

Signature

export declare const assertEmpty: (params?: {
  readonly name?: string
}) => MTypes.OneArgFunction<string, Either.Either<string, Type>>

assertInRange

Returns a right of input if input in between min and max included. Otherwise, returns a left of an InputError

Signature

export declare const assertInRange: (params: {
  readonly min: number
  readonly max: number
  readonly minIncluded: boolean
  readonly maxIncluded: boolean
  readonly offset: number
  readonly name?: string
}) => MTypes.OneArgFunction<number, Either.Either<number, Type>>

assertLength

Returns a right of input if input has the expected length. Otherwise, returns a left of an InputError

Signature

export declare const assertLength: (params: {
  readonly expected: number
  readonly name?: string
}) => <A extends ArrayLike<unknown> | string>(self: A) => Either.Either<A, Type>

assertMatches

Returns a right of input if input matches regExp. Otherwise, returns a left of an InputError

Signature

export declare const assertMatches: (params: {
  readonly regExp: RegExp
  readonly regExpDescriptor: string
  readonly name?: string
}) => MTypes.OneArgFunction<string, Either.Either<string, Type>>

assertMaxLength

Returns a right of input if the size of input is less than or equal to expected. Otherwise, returns a left of an InputError

Signature

export declare const assertMaxLength: (params: {
  readonly expected: number
  readonly name?: string
}) => <A extends ArrayLike<unknown> | string>(self: A) => Either.Either<A, Type>

assertStartsWith

Returns a right of input if input starts with startString. Otherwise, returns a left of an InputError

Signature

export declare const assertStartsWith: (params: {
  readonly startString: string
  readonly name?: string
}) => MTypes.OneArgFunction<string, Either.Either<string, Type>>

assertValue

Returns a right of input if input is equal to expected. Otherwise, returns a left of an InputError

Signature

export declare const assertValue: <T extends MTypes.NonNullablePrimitive>(params: {
  readonly expected: NoInfer<T>
  readonly name?: string
}) => MTypes.OneArgFunction<T, Either.Either<T, Type>>

match

Returns a right of the match if input matches regExp. Otherwise, returns a left of an InputError

Signature

export declare const match: (params: {
  readonly regExp: RegExp
  readonly regExpDescriptor: string
  readonly name?: string
}) => (self: string) => Either.Either<string, Type>

missized

Builds an Input error that signals a missized ArrayLike

Signature

export declare const missized: ({
  expected,
  actual,
  name
}: {
  readonly expected: number
  readonly actual: number
  readonly name?: string
}) => Type

notEmpty

Builds an Input error that signals a string that is not empty

Signature

export declare const notEmpty: ({ actual, name }: { readonly actual: string; readonly name?: string }) => Type

notMatching

Builds an Input error that signals a string not matching regExp

Signature

export declare const notMatching: ({
  regExpDescriptor,
  actual,
  name
}: {
  readonly regExpDescriptor: string
  readonly actual: string
  readonly name?: string
}) => Type

notStartingWith

Builds an Input error that signals a string not starting with startString

Signature

export declare const notStartingWith: ({
  startString,
  actual,
  name
}: {
  readonly startString: string
  readonly actual: string
  readonly name?: string
}) => Type

outOfBounds

Builds an Input error that signals a value out of bounds

Signature

export declare const outOfBounds: ({
  min,
  max,
  minIncluded,
  maxIncluded,
  offset,
  actual,
  name
}: {
  readonly min: number
  readonly max: number
  readonly minIncluded: boolean
  readonly maxIncluded: boolean
  readonly offset: number
  readonly actual: number
  readonly name?: string
}) => Type

oversized

Builds an Input error that signals an oversized ArrayLike

Signature

export declare const oversized: ({
  expected,
  actual,
  name
}: {
  readonly expected: number
  readonly actual: number
  readonly name?: string
}) => Type

wrongValue

Builds an Input error that signals a wrong value

Signature

export declare const wrongValue: <T extends MTypes.NonNullablePrimitive>({
  expected,
  actual,
  name
}: {
  readonly expected: T
  readonly actual: T
  readonly name?: string
}) => Type

Models

Type (class)

Type of an InputError

Signature

export declare class Type

Module markers

moduleTag

Module tag

Signature

export declare const moduleTag: "@parischap/effect-lib/InputError/"