diff --git a/README.md b/README.md index 340990d..59c3efc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Gem Version](https://badge.fury.io/rb/sorbet-coerce.svg)](https://badge.fury.io/rb/sorbet-coerce) [![Build Status](https://travis-ci.com/chanzuckerberg/sorbet-coerce.svg?branch=master)](https://travis-ci.com/chanzuckerberg/sorbet-coerce) -Type coercion for [Sorbet](https://sorbet.org) +A type coercion lib works with [Sorbet](https://sorbet.org)'s static type checker and type definitions; raises an error if the coercion fails. ## Installation 1. Follow the steps [here](https://sorbet.org/docs/adopting) to set up the latest version of Sorbet and run `srb tc`. @@ -26,7 +26,21 @@ converted = T::Coerce[].new.from() T.reveal_type(converted) # ``` -- Simple Type + + +### Supported Types +- Simple Types +- Custom Types: If the values can be coerced by `.new` +- `T.nilable()` +- `T::Array[]` +- Subclasses of `T::Struct` + +We don't support +- `T::Hash` (currently) +- `T.any(, ...)`: A union type other than `T.nilable` + +### Examples +- Simple Types ```ruby T::Coerce[Date].new.from('2019-08-05')