Update README

This commit is contained in:
Tobe O 2018-05-15 15:36:06 -04:00
parent 76129721f2
commit 90f7243c6b

View file

@ -10,6 +10,7 @@ the time you spend writing boilerplate serialization code for your models.
* [Models](#models) * [Models](#models)
* [Field Aliases](#aliases) * [Field Aliases](#aliases)
* [Excluding Keys](#excluding-keys) * [Excluding Keys](#excluding-keys)
* [Required Fields](#required-fields)
* [Serialization](#serializaition) * [Serialization](#serializaition)
* [Nesting](#nesting) * [Nesting](#nesting)
* [ID and Date Fields](#id-and-dates) * [ID and Date Fields](#id-and-dates)
@ -184,6 +185,25 @@ abstract class _Whisper extends Model {
} }
``` ```
## Required Fields
It is easy to mark a field as required; just use the
`@required` annotation from `package:meta`:
```dart
@serializable
abstract class _Foo extends Model {
@required
int myRequiredInt;
@Required('Custom message')
int myOtherRequiredInt;
}
```
The given field will be marked as `@required` in the
generated constructor, and serializers will check for its
presence, throwing a `FormatException` if it is missing.
# Nesting # Nesting
`angel_serialize` also supports a few types of nesting of `@serializable` classes: `angel_serialize` also supports a few types of nesting of `@serializable` classes:
* As a class member, ex. `Book myField` * As a class member, ex. `Book myField`