**N.B.: **It is important to stick to using the `setDataValue()` and `getDataValue()` functions (as opposed to accessing the underlying "data values" property directly) - doing so protects your custom getters and setters from changes in the underlying model implementations (i.e. how and where data values are stored in your model instances)
### Setter methods and Object Initialization
!!!TODO: write about how setters affect object initialization (both creating new objects with Model.build and retrieving existing objects from storage)!!!!!
## Validations
Model validations, allow you to specify format/content/inheritance validations for each attribute of the model. You can perform the validation by calling the `validate()` method on an instance before saving. The validations are implemented by [validator][3].
Model validations, allow you to specify format/content/inheritance validations for each attribute of the model.
**Note: **In `v1.7.0` validations will now be called when executing the `build()` or `create()` functions.
Validations are automatically run on `create`, `update` and `save`. You can also call `validate()` to manually validate an instance.
The validations are implemented by [validator][3].
```js
varValidateMe=sequelize.define('Foo',{
...
...
@@ -309,11 +307,11 @@ See [the node-validator project][4]for more details on the built in validation m
### Validators and`allowNull`
Since `v1.7.0` if a particular field of a model is set to allow null (with `allowNull: true`) and that value has been set to `null`, its validators do not run. This means you can, for instance, have a string field which validates its length to be at least 5 characters, but which also allows`null`.
If a particular field of a model is set to allow null (with `allowNull: true`) and that value has been set to `null`, its validators do not run. This means you can, for instance, have a string field which validates its length to be at least 5 characters, but which also allows`null`.
### Model validations
Since `v1.7.0`, validations can also be defined to check the model after the field-specific validators. Using this you could, for example, ensure either neither of `latitude` and `longitude` are set or both, and fail if one but not the other is set.
Validations can also be defined to check the model after the field-specific validators. Using this you could, for example, ensure either neither of `latitude` and `longitude` are set or both, and fail if one but not the other is set.
Model validator methods are called with the model object's context and are deemed to fail if they throw an error, otherwise pass. This is just the same as with custom field-specific validators.