README.md in flexirest-1.3.32 vs README.md in flexirest-1.3.33
- old
+ new
@@ -957,11 +957,11 @@
```ruby
class Person < Flexirest::Base
validates :first_name, presence: true #ensures that the value is present and not blank
validates :last_name, existence: true #ensures that the value is non-nil only
- validates :password, length: {within:6..12}
+ validates :password, length: {within:6..12}, message: "Invalid password length, must be 6-12 characters"
validates :post_code, length: {minimum:6, maximum:8}
validates :salary, numericality: true, minimum: 20_000, maximum: 50_000
validates :age, numericality: { minumum: 18, maximum: 65 }
validates :suffix, inclusion: { in: %w{Dr. Mr. Mrs. Ms.}}
@@ -975,10 +975,10 @@
Note: the block based validation is responsible for adding errors to `object._errors[name]` (and this will automatically be ready for `<<` inserting into).
Validations are run when calling `valid?` or when calling any API on an instance (and then only if it is `valid?` will the API go on to be called).
-`full_error_messages` returns an array of attributes with their associated error messages, i.e. `["age must be at least 18"]`
+`full_error_messages` returns an array of attributes with their associated error messages, i.e. `["age must be at least 18"]`. Custom messages can be specified by passing a `:message` option to `validates`. This differs slightly from ActiveRecord in that it's an option to `validates` itself, not a part of a final hash.
#### Permitting nil values
The default behavior for `:length`, `:numericality` and `:inclusion` validators is to fail when a `nil` value is encountered. You can prevent `nil` attribute values from triggering validation errors for attributes that may permit `nil` by adding the `:allow_nil => true` option. Adding this option with a `true` value to `:length`, `:numericality` and `:inclusion` validators will permit `nil` values and not trigger errors. Some examples are:
```ruby