DO NOT USE
This gem is not maintained or used anymore. Use Defra ruby validators instead
Add this line to your application's Gemfile
gem 'ea-validation'
And then execute
$ bundle
Or install it yourself as
$ gem install ea-validation
With this gem installed, a number of active model based validators become available.
There are a number of restrictions as to what comprises a company name valid for Companies House registration. This validator checks that the name complies to these restrictions.
validates :company_name, "ea/validation/companies_house_name" => true
This validator checks that the name complies to the maximum company name length restriction.
validates :name, "ea/validation/companies_house_name_length" => true
As with company names, there are also restrictions to the form of a company registration number. This validator checks that the company registration number complies to these restrictions.
validates :number, "ea/validation/companies_house_number" => true
A locale hint is available for your views, that details the restrictions, e.g
<span class="form-hint"><%= t('ea.validation.errors.companies_house_number.hint') %></span>
A grid reference should be of the form AA 12345 67890 (spaces optional). The validator checks the format, and the the grid reference is valid.
validates :grid_reference, "ea/validation/grid_reference" => true
Use the following format, to also check for the presence of the grid reference.
validates :grid_reference, presence: { message: I18n.t("ea.validation.errors.grid_reference.blank") }
validates :grid_reference, "ea/validation/grid_reference" => true, allow_blank: true
Check a text field contains only letters and EA allowable characters.
validates :some_text_field, "ea/validation/text_only_content_validator" => true
Use the following format, to also check for the presence of text, pass required field name to the error message.
validates :name, presence: { message: I18n.t("ea.validation.errors.text_only_content.blank", field: 'name') }
validates :name, "ea/validation/text_only_content": true, allow_blank: true
Options can be passed into validation by replacing true
with an options hash. For example
validates(:grid_reference,"ea/validation/grid_reference" => {message: "Custom message to display", allow_blank: true})
If you have an idea you'd like to contribute please log an issue.
All contributions should be submitted via a pull request.
THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:
http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3
The following attribution statement MUST be cited in your products and applications when using this information.
Contains public sector information licensed under the Open Government license v3
The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.
It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.