String Types For io-ts

Overview

io-ts-strings

Test

String types for io-ts

npm install io-ts-strings

Currently implemented types:

  • Alpha
  • AlphaNumeric
  • Ascii
  • Base32, Base58, Base64
  • BIC(SWIFT Code)
  • BitcoinAddress
  • Char(String of length 1)
  • CountryCode, CountryCode2 (e.g. "US"), CountryCode3 (e.g. "USA")
  • CreditCard, Visa, Mastercard
  • DataURI (e.g. "data:,Hello%2C%20World%21")
  • EAN(European Article Number)
  • Email
  • Empty(i.e. "")
  • EthereumAddress
  • MD4, MD5, SHA1, SHA256
  • Hexadecimal
  • HexColor (e.g. "#eb4034")
  • HostName (e.g. "localhost:3000", "foo.example.com")
  • HSL (hue, saturation, lightness)
  • IBAN(International Bank Account Number)
  • IP (either v4 or v6), IPv6, IPv4
  • IPRange (E.g. "255.255.255.255/30"), IPRangev6, IPRangev6
  • ISIN (International Securities Identification Number)
  • ISRC (International Standard Recording Code)
  • ISSN (International Standard Serial Number)
  • JWT (JSON Web Token)
  • LatLong (e.g. "lat,long", "lat, long")
  • Locale
  • Lowercase
  • MacAddress
  • MagnetURI
  • MongoID (MongoDB Object ID)
  • NonEmpty
  • Numeric
  • Octal
  • PassportNumber (By country. E.g. PassportNumberUS)
  • PhoneNumber (By Country. E.g. PhoneNumberUS)
  • Port
  • PostalCode (By Country. E.g. PostalCodeUS)
  • SemVer (Semantic Version Number)
  • StrongPassword
  • Uppercase
  • URL
  • UUID (v3, v4, or v5), UUIDv3, UUIDv4, UUIDv5

Whenever a string type depends on locale(e.g phone number) multiple different codecs are supplied for each country. For example PhoneNumberFR. Currently supported locals are:

  • The United States(US)
  • Germany(DE)
  • France(FR)

Examples

import * as t from 'io-ts'
import Email from 'io-ts-strings/dist/Email'
// import { Email } from 'io-ts-strings'

const codec = t.interface({
  email: Email,
})

codec.decode({ email: '[email protected]' }) // Right
codec.decode({ email: 'john.com' }) // Left
You might also like...

đŸ§© TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)

đŸ§© TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)

đŸ§© TypeScript Primitives type TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types

Dec 7, 2022

🔒 The new way to do types in typescript.

Nominal The right way to do types in typescript. Installation npm install nominal-types yarn install nominal-types pnpm install nominal-types Usage

Dec 24, 2022

jQuery pop-up script displaying various types of content in corner of browser

Corner Popup v1.30 Fully customizable pop-up box created to display all types of messages in corner of your browser. Website: https://espritdesign.pl/

Nov 27, 2022

A little utility type package that allows you to access the current TypeScript version from your types.

@phryneas/ts-version A little utility type package that allows you to access the current TypeScript version from your types. import { TSVersion } from

Sep 4, 2022

You can easily create the horizontal timeline with two types by using this jQuery plugin.

You can easily create the horizontal timeline with two types by using this jQuery plugin.

jQuery.Timeline V2 You are able to easily create two types of horizontal timeline with this jQuery plugin. Report bug · Request feature · Blog Table o

Dec 9, 2022

Functions for testing the types of JavaScript values, cross-realm. Has testers for all standard built-in objects/values.

@suchipi/is Functions for testing the types of JavaScript values, cross-realm. Has testers for all standard built-in objects/values. Usage import { is

Sep 8, 2022

Minimalistic configuration for TS to only extend JS with types. No TS features, no bundling. Readable maintainable code after compilation.

Minimalistic configuration for TS to only extend JS with types. No TS features, no bundling. Readable maintainable code after compilation.

ts-guideline Minimalistic configuration for TS to only extend JS with types. No TS-scpecific features, no bundling. Readable maintainable code after c

Dec 22, 2022

🎊 A Collection of TypeScript types for the Kirby CMS

kirby-fest A collection of TypeScript types to work with Kirby, mainly in the context of the Kirby Query Language. Setup # pnpm pnpm add -D kirby-fest

Nov 22, 2022

100% type-safe query builder for node-postgres :: Generated types, call any function, tree-shakable, implicit type casts, and more

⚠ This library is currently in alpha. Contributors wanted! tusken Postgres client from a galaxy far, far away. your database is the source-of-truth f

Dec 29, 2022
Releases(v1.0.0)
Owner
Jesse Kelly
Hello, and welcome to my Github page! I'm glad you made it. Here, have some tea. Please, have a look around!
Jesse Kelly
String Types For io-ts

io-ts-strings String types for io-ts npm install io-ts-strings Currently implemented types: Alpha AlphaNumeric Ascii Base32, Base58, Base64 BIC(SWIFT

Jesse Kelly 5 Mar 13, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till mÀnniskor pÄ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Convert some JavaScript/TypeScript code string into a .d.ts TypeScript Declaration code string

convert-to-dts Converts the source code for any .js or .ts file into the equivalent .d.ts code TypeScript would generate. Usage import { convertToDecl

Lily Scott 11 Mar 3, 2022
Different Types of Monsters Card of Popular anime. Build in React tech.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: ya

Abhishek Tiwari 5 Mar 19, 2022
Basic types & utilities for Strapi v4 and plugin creators

Strapi v4 - Types & utilities Basic set of types and utilities for Strapi v4 and plugins creators A developers goodie for Strapi Headless CMS which pr

 VirtusLab Open-Source 7 Oct 14, 2022
Variant types in Roblox TypeScript - Ported from Vanilla TypeScript

Variant (for Roblox) This is a roblox typescript variant (heh, pun) of Variant. See the Variant documentation on how to use Variant. A variant type is

Australis 2 Jun 3, 2022
Simple "everyday CRUD" Postgres queries with perfect TypeScript types

Crudely Typed Simple "everyday CRUD" Postgres queries with perfect TypeScript types. Zero dependencies. Designed to work with pg-to-ts and node-postgr

Dan Vanderkam 26 Dec 26, 2022
well yes, but can you do it in types?

Yes, but can you do it in types? A collection of challenges which you complete in solely the type system. Everyone knows you can write code to do thin

catgirlkelly 11 Oct 27, 2022