You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-9Lines changed: 45 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,18 @@
1
-
# SiretFormatValidator
1
+
_TODO: add badges_
2
2
3
-
TODO: Delete this and the text below, and describe your gem
3
+
# siret_validator
4
4
5
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/siret_validator`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+
This gem provides a Rails validator for french [SIRET numbers](https://entreprendre.service-public.fr/vosdroits/F32135?lang=en).
6
6
7
-
## Installation
7
+
## Features
8
+
9
+
* Validate the SIRET format (14 digits),
10
+
* Validate the checksum of regular SIRETs (with luhn sum),
11
+
* Validate the checksum of La Poste SIRETs (with the alternative checksum formula),
12
+
* Clear localized error messages,
13
+
* Ad-hoc error messages support.
8
14
9
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
15
+
## Installation
10
16
11
17
Install the gem and add to the application's Gemfile by executing:
12
18
@@ -20,19 +26,49 @@ If bundler is not being used to manage dependencies, install the gem by executin
Alternatively, you can vendor the gem by just copy-pasting the `lib/siret_validator.rb` file into your `app/validators` directory.
30
+
23
31
## Usage
24
32
25
-
TODO: Write usage instructions here
33
+
### With ActiveRecord
34
+
35
+
```ruby
36
+
classTaxesFilling < ApplicationRecord
37
+
validates :company_siret, siret:true
38
+
end
39
+
```
40
+
41
+
### With ActiveModel
42
+
43
+
```ruby
44
+
classTaxesFilling
45
+
includeActiveModel::Validations
46
+
47
+
attr_accessor:company_siret
48
+
validates :company_siret, siret:true
49
+
end
50
+
```
51
+
52
+
## I18n
53
+
54
+
By default, the siret validator may emit two different error messages:
55
+
56
+
*`:wrong_siret_format` – when the value is not an 14-digits string.
57
+
58
+
_The message is localized using a custom `:wrong_siret_format` i18n key. French and English locales are bundled with the gem._
59
+
*`:invalid` – when the SIRET checksum is invalid.
60
+
61
+
_The message is localized using the standard Rails `:invalid` i18n key._
26
62
27
63
## Development
28
64
29
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
65
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
30
66
31
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
67
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `siret_validator.gemspec`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
68
33
69
## Contributing
34
70
35
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/siret_validator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/siret_validator/blob/main/CODE_OF_CONDUCT.md).
71
+
Bug reports and pull requests are welcome on GitHub at https://github.com/CodeursenLiberte/siret_validator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/CodeursenLiberte/siret_validator/blob/main/CODE_OF_CONDUCT.md).
0 commit comments