{"id":21069636,"url":"https://github.com/mtarnovan/romanianvalidators","last_synced_at":"2025-07-24T14:36:18.116Z","repository":{"id":5465111,"uuid":"6660530","full_name":"mtarnovan/romanianvalidators","owner":"mtarnovan","description":"Collection of validations for Cod Numeric Personal (CNP), Cod de identificare fiscală (CIF) and IBAN (only Romanian format, as published by Romanian National Bank","archived":false,"fork":false,"pushed_at":"2018-04-12T19:01:18.000Z","size":36,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T23:19:14.625Z","etag":null,"topics":["activemodel","bic","cif","cnp","iban","rails","ruby","validations"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtarnovan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-12T20:57:56.000Z","updated_at":"2018-04-26T09:03:15.000Z","dependencies_parsed_at":"2022-07-06T19:03:28.358Z","dependency_job_id":null,"html_url":"https://github.com/mtarnovan/romanianvalidators","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtarnovan%2Fromanianvalidators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtarnovan%2Fromanianvalidators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtarnovan%2Fromanianvalidators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtarnovan%2Fromanianvalidators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtarnovan","download_url":"https://codeload.github.com/mtarnovan/romanianvalidators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254470303,"owners_count":22076566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activemodel","bic","cif","cnp","iban","rails","ruby","validations"],"created_at":"2024-11-19T18:36:27.499Z","updated_at":"2025-05-16T04:34:27.745Z","avatar_url":"https://github.com/mtarnovan.png","language":"Ruby","readme":"# Romanian Validators [![Build Status](https://travis-ci.org/mtarnovan/romanianvalidators.svg?branch=master)](https://travis-ci.org/mtarnovan/romanianvalidators) [![Gem Version](https://badge.fury.io/rb/romanianvalidators.svg)](https://badge.fury.io/rb/romanianvalidators) [![Code Climate](https://codeclimate.com/github/mtarnovan/romanianvalidators/badges/gpa.svg)](https://codeclimate.com/github/mtarnovan/romanianvalidators)\n\nValidators for:\n\n  * Cod Numeric Personal (CNP)\n  * Cod de identificare fiscală (CIF) and\n  * IBAN (only Romanian format as published by Romanian National Bank).\n  * BIC\n\nExtracted from [openapi.ro](https://openapi.ro), business APIs for Romanian developers.\nIncludes `ActiveModel` validators.\n\n## Installation\n\nInclude it in your `Gemfile`. If you just want the validation, without `ActiveModel`, use:\n\n    gem 'romanianvalidators'\n\nIf you want ActiveModel integration, use instead:\n\n    gem 'romanianvalidators', require: 'romanian_validators/active_model'\n\nHas no other dependency (other than `ActiveModel` if you require it).\n\nTested with MRI 1.9.3, 2.0, 2.1, 2.3, REE, Rubinius and JRuby (see `.travis.yml`)\n\n## Usage\n\nWithout `ActiveModel`, just call the `valid?` method on the corresponding module\n\n```ruby\n    \u003e RomanianValidators::Cif.valid?(13548146)\n    =\u003e true\n    \u003e RomanianValidators::Iban.valid?(123)\n    =\u003e false\n ```\n\nWith `ActiveModel`, include it in your model\n\n```ruby\n    include RomanianValidators::ActiveModel::Validations\n```\n\nthen use like this:\n\n```ruby\n    validates :my_attribute, cif: true\n```\n\nExample:\n```ruby\n    class User\n      include ActiveModel::Model\n      include RomanianValidators::ActiveModel::Validations\n      attr_accessor :cnp, :company_cif\n\n      validates :cnp, cnp: { message: 'This is not a valid CNP' }\n      validates :company_cif, cif: true\n    end\n\n    \u003e u = User.new(cnp: 123, company_cif: 123)\n    =\u003e #\u003cUser:0x007fbf7f959b38 @cnp=123, @company_cif=123\u003e\n    \u003e u.valid?\n    =\u003e false\n    \u003e u.errors\n    =\u003e #\u003cActiveModel::Errors:0x007fbf80958548 @base=#\u003cUser:0x007fbf7f959b38 @cnp=123, @company_cif=123, @validation_context=nil, @errors=#\u003cActiveModel::Errors:0x007fbf80958548 ...\u003e\u003e, @messages={:cnp=\u003e[\"This is not a valid CNP\"], :company_cif=\u003e[\"is invalid\"]}, @details={:cnp=\u003e[{:error=\u003e\"This is not a valid CNP\"}], :company_cif=\u003e[{:error=\u003e:invalid}]}\u003e\n```\n\nFor CIFs, a (lazy) enumerator is provided. This enumerator is significantly\nmore efficient than iterating over a range of numbers and filtering valid CIFs, because\nit generates the control digit from `cif % 10` directly.\n\nExample:\n\n```ruby\n\u003e RomanianValidators::Cif.enumerator(1).take(10).to_a\n=\u003e [19, 27, 35, 43, 51, 60, 78, 86, 94, 108]\n\u003e RomanianValidators::Cif.enumerator(1_000_000, :down).take(10).to_a\n=\u003e [999993, 999985, 999977, 999969, 999950, 999942, 999934, 999926, 999918, 999900]\n```\n\n### Upgrading\n\nIf upgrading from `0.1.x`, note that the `ActiveModel` validations are now in a separate module so you need to add\n`include RomanianValidators::ActiveModel::Validations` in your models. Additionaly you need to add a `require` in your Gemfile (again, only if using `ActiveModel`):\n\n```ruby\n  gem 'romanianvalidators', require: 'romanianvalidators/active_model'\n```\n\n### Changelog\n\n#### 0.2.0\n* moved validations from `ActiveModel::Validations` to `RomanianValidators::ActiveModel::Validations`.\n  This module must be manually required in models.\n* added a lazy enumerator that generates valid CIFs: `RomanianValidators::Cif.enumerator(start, direction = :up)`\n\n### Copyright\n\nCopyright (c) 2007-2018 Mihai Târnovan. MIT LICENSE. See LICENSE for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtarnovan%2Fromanianvalidators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtarnovan%2Fromanianvalidators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtarnovan%2Fromanianvalidators/lists"}