Overview
Collection for String
Table of contents
- EMailBrand (interface)
- EmailBrand (interface)
- IpV4Brand (interface)
- IpV6Brand (interface)
- NonEmptyStringBrand (interface)
- NonEmptyStringC (interface)
- StringMatchBrand (interface)
- StringMaxLengthBrand (interface)
- StringMinLengthBrand (interface)
- UUIDBrand (interface)
- UrlBrand (interface)
- NonEmptyString (type alias)
- UUID (type alias)
- Url (type alias)
- email (type alias)
- ipv4 (type alias)
- ipv6 (type alias)
- email (constant)
- ipv4 (constant)
- ipv6 (constant)
- nonEmptyString (constant)
- url (constant)
- uuid (constant)
- stringMatch (function)
- stringMaxLength (function)
- stringMinLength (function)
EMailBrand (interface)
Signature
interface EMailBrand {
readonly EMail: unique symbol
}
Added in v0.2.0
EmailBrand (interface)
Signature
interface EmailBrand {
readonly email: unique symbol
}
Added in v0.2.0
IpV4Brand (interface)
Signature
interface IpV4Brand {
readonly ipv4: unique symbol
}
Added in v0.2.0
IpV6Brand (interface)
Signature
interface IpV6Brand {
readonly ipv6: unique symbol
}
Added in v0.2.0
NonEmptyStringBrand (interface)
Signature
interface NonEmptyStringBrand {
readonly NonEmptyString: unique symbol
}
Added in v0.2.0
NonEmptyStringC (interface)
Signature
interface NonEmptyStringC extends Type {}
Added in v0.2.0
StringMatchBrand (interface)
Signature
interface StringMatchBrand {
readonly StringMatch: unique symbol
}
Added in v0.2.0
StringMaxLengthBrand (interface)
Signature
interface StringMaxLengthBrand {
readonly StringMaxLength: unique symbol
}
Added in v0.2.0
StringMinLengthBrand (interface)
Signature
interface StringMinLengthBrand {
readonly StringMinLength: unique symbol
}
Added in v0.2.0
UUIDBrand (interface)
Signature
interface UUIDBrand {
readonly UUID: unique symbol
}
Added in v0.2.0
UrlBrand (interface)
Signature
interface UrlBrand {
readonly Url: unique symbol
}
Added in v0.2.0
NonEmptyString (type alias)
Signature
export type NonEmptyString = t.Branded<string, NonEmptyStringBrand>
Added in v0.2.0
UUID (type alias)
Signature
export type UUID = t.Branded<string, UUIDBrand>
Added in v0.2.0
Url (type alias)
Signature
export type Url = t.Branded<string, UrlBrand>
Added in v0.2.0
email (type alias)
Signature
export type email = t.Branded<string, EmailBrand>
Added in v0.2.0
ipv4 (type alias)
Signature
export type ipv4 = t.Branded<string, IpV4Brand>
Added in v0.2.0
ipv6 (type alias)
Signature
export type ipv6 = t.Branded<string, IpV6Brand>
Added in v0.2.0
email (constant)
A codec that succeeds if a string is EMAIL.
Signature
export const email: t.BrandC<t.StringC, EmailBrand> = ...
Example
import { email } from 'macoolka-io'
import { right, isLeft } from 'fp-ts/lib/Either'
expect(email.decode('a@mail.com')).toEqual(right('a@mail.com'))
expect(isLeft(email.decode('12'))).toEqual(true)
Added in v0.2.0
ipv4 (constant)
A codec that succeeds if a string is IPV4.
Signature
export const ipv4: t.BrandC<t.StringC, IpV4Brand> = ...
Example
import { ipv4 } from 'macoolka-io'
import { right, isLeft } from 'fp-ts/lib/Either'
expect(ipv4.decode('8.8.8.8')).toEqual(right('8.8.8.8'))
expect(isLeft(ipv4.decode('12'))).toEqual(true)
Added in v0.2.0
ipv6 (constant)
A codec that succeeds if a string is IPV6.
Signature
export const ipv6: t.BrandC<t.StringC, IpV6Brand> = ...
Example
import { ipv6 } from 'macoolka-io'
import { right, isLeft } from 'fp-ts/lib/Either'
expect(ipv6.decode('2409:8a15:244a:a780:b0f5:8e9a:2c2e:5ce2')).toEqual(right('2409:8a15:244a:a780:b0f5:8e9a:2c2e:5ce2'))
expect(isLeft(ipv6.decode('8.8.8.8'))).toEqual(true)
Added in v0.2.0
nonEmptyString (constant)
A codec that succeeds if a string is not empty
Signature
export const nonEmptyString: NonEmptyStringC = ...
Example
import { NonEmptyString } from 'macoolka-io'
import { right, isLeft } from 'fp-ts/lib/Either'
assert.deepStrictEqual(NonEmptyString.decode('a'), right('a'))
assert(isLeft(NonEmptyString.decode('')))
Added in v0.2.0
url (constant)
A codec that succeeds if a string is url.
Signature
export const url: t.BrandC<t.StringC, UrlBrand> = ...
Example
import { url } from 'macoolka-io'
import { right, isLeft } from 'fp-ts/lib/Either'
expect(url.decode('http://bing.com')).toEqual(right('http://bing.com'))
expect(isLeft(url.decode('8.8.8.8'))).toEqual(true)
Added in v0.2.0
uuid (constant)
A codec that succeeds if a string is UUID.
Signature
export const uuid: t.BrandC<t.StringC, UUIDBrand> = ...
Example
import { uuid } from 'macoolka-io'
import { right, isLeft } from 'fp-ts/lib/Either'
Added in v0.2.0
stringMatch (function)
A codec that succeeds if a string match a RegExp.
Signature
export const stringMatch = (regexp: RegExp) => new t.Type<string, string, unknown>(
['stringMatch', regexp].join(NameSplit),
t.string.is,
(u, c) => ...
Example
import { stringMatch } from 'macoolka-io'
import { right, isLeft } from 'fp-ts/lib/Either'
expect(stringMatch(/^A/).decode('ABC')).toEqual(right('ABC'))
expect(isLeft(stringMatch(/^A/).decode('12'))).toEqual(true)
Added in v0.2.0
stringMaxLength (function)
A codec that succeeds if a string max length is given value.
Signature
export const stringMaxLength = (_maxLength: number) => new t.Type<string, string, unknown>(
['stringMaxLength', _maxLength].join(NameSplit),
t.string.is,
(u, c) => ...
Example
import { stringMaxLength } from 'macoolka-io'
import { right, isLeft } from 'fp-ts/lib/Either'
expect(t.stringMaxLength(3).decode('123')).toEqual(right('123'))
expect(isLeft(t.stringMaxLength(3).decode('1234'))).toEqual(true)
Added in v0.2.0
stringMinLength (function)
A codec that succeeds if a string min length is given value.
Signature
export const stringMinLength = (_minLength: number) => new t.Type<string, string, unknown>(
['stringMinLength', _minLength].join(NameSplit),
t.string.is,
(u, c) => ...
Example
import { stringMinLength } from 'macoolka-io'
import { right, isLeft } from 'fp-ts/lib/Either'
expect(stringMinLength(3).decode('123')).toEqual(right('123'))
expect(isLeft(stringMinLength(3).decode('12'))).toEqual(true)
Added in v0.2.0