diff --git a/README.md b/README.md index c970667..3275423 100644 --- a/README.md +++ b/README.md @@ -233,20 +233,24 @@ enum ISODateTransformer: Transformer { } ``` -Then you define the attribute as a `TransformAttribute` instead of an `Attribute`: +Then you define the attribute as a `TransformedAttribute` instead of an `Attribute`: ``` -let date: TransformAttribute +let date: TransformedAttribute ``` Note that the first generic parameter of `TransformAttribute` is the type you expect to decode from JSON, not the type you want to end up with after transformation. +#### `Validator` + +You can also creator `Validator`s and `ValidatedAttribute`s. A `Validator` is just a `Transformer` that by convention does not perform a transformation. It simply `throws` if an attribute value is invalid. + ### `JSONAPIDocument` The entirety of a JSON API request or response is encoded or decoded from- or to a `JSONAPIDocument`. As an example, a JSON API response containing one `Person` and no included entities could be decoded as follows: ``` let decoder = JSONDecoder() -let responseStructure = JSONAPIDocument, NoMetadata, NoIncludes, BasicJSONAPIError>.self +let responseStructure = JSONAPIDocument, NoMetadata, NoLinks, NoIncludes, BasicJSONAPIError>.self let document = try decoder.decode(responseStructure, from: data) ```