README.md in judge-2.1.1 vs README.md in judge-3.0.0

- old
+ new

@@ -10,11 +10,12 @@ In many cases it would be simpler to safely expose the validation information from our models to the client – this is where Judge steps in. ## Installation -Judge supports Rails >= 3.1. +Judge supports Rails 5.0+. +If you require Rails 4 support, please use version 2.1.x. Judge relies on [Underscore.js](underscore) in general and [JSON2.js](json2) for browsers that lack proper JSON support. If your application already makes use of these files, you can safely ignore the versions provided with Judge. ### With asset pipeline enabled @@ -114,12 +115,53 @@ * acceptance; * confirmation (input and confirmation input must have matching ids); * uniqueness; * any `EachValidator` that you have written, provided you add a JavaScript version too and add it to `judge.eachValidators`. -The *allow_blank* option is available everywhere it should be. Error messages are looked up according to the [Rails i18n API](http://guides.rubyonrails.org/i18n.html#translations-for-active-record-models). +The *allow_blank* option is available everywhere it should be. +### Error messages +Error messages are looked up according to the [Rails i18n API](http://guides.rubyonrails.org/i18n.html#error-message-interpolation). + +To override error messages, add entries to `config/locales/en.yml` for the messages you'd like to customize. Here's an example with Rails default values: +``` +en: + errors: + format: "%{attribute} %{message}" + messages: + accepted: must be accepted + blank: can't be blank + present: must be blank + confirmation: doesn't match %{attribute} + empty: can't be empty + equal_to: must be equal to %{count} + even: must be even + exclusion: is reserved + greater_than: must be greater than %{count} + greater_than_or_equal_to: must be greater than or equal to %{count} + inclusion: is not included in the list + invalid: is invalid + less_than: must be less than %{count} + less_than_or_equal_to: must be less than or equal to %{count} + model_invalid: "Validation failed: %{errors}" + not_a_number: is not a number + not_an_integer: must be an integer + odd: must be odd + required: must exist + taken: has already been taken + too_long: + one: is too long (maximum is 1 character) + other: is too long (maximum is %{count} characters) + too_short: + one: is too short (minimum is 1 character) + other: is too short (minimum is %{count} characters) + wrong_length: + one: is the wrong length (should be 1 character) + other: is the wrong length (should be %{count} characters) + other_than: must be other than %{count} +``` + ## Validating uniqueness In order to validate uniqueness Judge sends requests to the mounted `Judge::Engine` path, which responds with a JSON representation of an error message array. The array is empty if the value is valid. Since this effectively means adding an open, queryable endpoint to your application, Judge is cautious and requires you to be explicit about which attributes from which models you would like to expose for validation via XHR. Allowed attributes are configurable as in the following example. Note that you are only required to do this for `uniqueness` and any other validators you write that make requests to the server. @@ -319,8 +361,8 @@ $ bundle exec rake appraisal ``` ## Credit -Created by [Joe Corcoran](mailto:joecorcoran@gmail.com), whose [blog](http://blog.joecorcoran.co.uk) and [tweets](http://twitter.com/josephcorcoran) you can read on the world wide internet. Thank you to every user, email corresponder and pull request submitter. +Created by [Joe Corcoran](https://corcoran.io). Thank you to every user, email corresponder and pull request submitter. [Released under an MIT license](https://github.com/joecorcoran/judge/blob/master/LICENSE.txt).