Skip to content

Commit

Permalink
Update README.md (#2)
Browse files Browse the repository at this point in the history
Be more detailed and explicit about the supported/unsupported features.
  • Loading branch information
donaldong authored Oct 16, 2019
1 parent 68ee46b commit 405b326
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -26,7 +26,21 @@ converted = T::Coerce[<Type>].new.from(<value>)
T.reveal_type(converted) # <Type>
```

- Simple Type


### Supported Types
- Simple Types
- Custom Types: If the values can be coerced by `.new`
- `T.nilable(<supported type>)`
- `T::Array[<supported type>]`
- Subclasses of `T::Struct`

We don't support
- `T::Hash` (currently)
- `T.any(<supported type>, ...)`: A union type other than `T.nilable`

### Examples
- Simple Types

```ruby
T::Coerce[Date].new.from('2019-08-05')
Expand Down

0 comments on commit 405b326

Please sign in to comment.