Evolution SDK

Text.ts

Text overview


Table of contents


composition

between

Creates a curried filter that validates text length is within a range. Preserves Context inference from the base schema.

Signature

export declare const between: (
  min: number,
  max: number,
  moduleName: string
) => <S extends Schema.Schema<any, string>>(baseSchema: S) => Schema.filter<S>

Added in v2.0.0

conversion

fromBytes

Convert bytes to text

Signature

export declare const fromBytes: (i: any, overrideOptions?: ParseOptions) => string

Added in v2.0.0

fromHex

Convert hex string to text

Signature

export declare const fromHex: (i: string, overrideOptions?: ParseOptions) => string

Added in v2.0.0

toBytes

Convert text to bytes

Signature

export declare const toBytes: (a: string, overrideOptions?: ParseOptions) => any

Added in v2.0.0

toHex

Convert text to hex string

Signature

export declare const toHex: (a: string, overrideOptions?: ParseOptions) => string

Added in v2.0.0

schemas

FromBytes

Schema for converting between strings and bytes (UTF-8).

text <-> bytes

Signature

export declare const FromBytes: Schema.transform<typeof Schema.Uint8ArrayFromSelf, typeof Schema.String>

Added in v2.0.0

FromHex

Schema for converting between strings and hex representation of UTF-8 bytes.

text <-> hex

Signature

export declare const FromHex: Schema.transform<Schema.Schema<Uint8Array, string, never>, typeof Schema.String>

Added in v2.0.0

testing

arbitrary

FastCheck arbitrary for generating random text strings

Signature

export declare const arbitrary: FastCheck.Arbitrary<string>

Added in v2.0.0

utils

Text

Signature

export declare const Text: typeof Schema.String

validation

length

Creates a schema that validates text length equals a specific value.

Signature

export declare const length: (
  length: number,
  identifier?: string
) => (self: Schema.Schema.Any) => Schema.filter<Schema.Schema.Any>

Added in v2.0.0

max

Creates a schema that validates text length is at most max.

Signature

export declare const max: (
  max: number,
  identifier?: string
) => (self: Schema.Schema.Any) => Schema.filter<Schema.Schema.Any>

Added in v2.0.0

min

Creates a schema that validates text length is at least min.

Signature

export declare const min: (
  min: number,
  identifier?: string
) => (self: Schema.Schema.Any) => Schema.filter<Schema.Schema.Any>

Added in v2.0.0