Created
June 24, 2017 18:24
-
-
Save kofno/b7b90148069504415299de947fd085b3 to your computer and use it in GitHub Desktop.
Array decoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { array, string } from 'jsonous'; | |
| const decoder = array(string()); | |
| decoder.decodeAny([ 'foo', 'bar' ]); // --> Ok(['foo', 'bar']) | |
| decoder.decodeAny('foo'); // --> Err('Expected an array. Instead found foo') | |
| decoder.decodeAny([ 'foo', 42, 'bar']); // --> Err('Error found in array at [1]: Expected a string. Instead found 42') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment