Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

io-ts-types

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ts-types

A collection of codecs and combinators for use with io-ts

  • 0.5.19
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
381K
increased by19.3%
Maintainers
1
Weekly downloads
 
Created

What is io-ts-types?

The io-ts-types package provides additional types and combinators for use with io-ts, a runtime type system for IO decoding/encoding in TypeScript. It extends the functionality of io-ts by offering more complex and useful types that are commonly needed in real-world applications.

What are io-ts-types's main functionalities?

DateFromISOString

This feature allows you to decode ISO string dates into JavaScript Date objects. It is useful for handling date strings in JSON APIs.

const { DateFromISOString } = require('io-ts-types');
const t = require('io-ts');

const DateType = DateFromISOString;

const result = DateType.decode('2023-10-01T00:00:00Z');
console.log(result); // Right(new Date('2023-10-01T00:00:00Z'))

NonEmptyString

This feature ensures that a string is not empty. It is useful for validating user input where empty strings are not allowed.

const { NonEmptyString } = require('io-ts-types');
const t = require('io-ts');

const NonEmptyStringType = NonEmptyString;

const result = NonEmptyStringType.decode('Hello');
console.log(result); // Right('Hello')

UUID

This feature validates that a string is a valid UUID. It is useful for ensuring that identifiers conform to the UUID format.

const { UUID } = require('io-ts-types');
const t = require('io-ts');

const UUIDType = UUID;

const result = UUIDType.decode('123e4567-e89b-12d3-a456-426614174000');
console.log(result); // Right('123e4567-e89b-12d3-a456-426614174000')

Option

This feature allows you to handle optional values in a functional way using the Option type from fp-ts. It is useful for dealing with nullable fields in a type-safe manner.

const { optionFromNullable } = require('io-ts-types');
const t = require('io-ts');

const OptionType = optionFromNullable(t.string);

const result = OptionType.decode(null);
console.log(result); // Right(none)

const result2 = OptionType.decode('Hello');
console.log(result2); // Right(some('Hello'))

Other packages similar to io-ts-types

Keywords

FAQs

Package last updated on 12 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc