Module: BrazilianUtils::RegistroProfissionalUtils
- Defined in:
- lib/brazilian-utils/registro-profissional-utils.rb
Overview
Note:
There were no acceptance test cases available in the contract for this function; this implementation follows the prose description as closely as possible but has not been cross-checked against a reference implementation's test suite.
Utilities for checking the structure of a professional council registration number (OAB, CRM, CRO, CRP or CRC). This never validates a check digit — none of these councils publish one — only the digit count and the UF.
Constant Summary collapse
- UFS =
%w[ AC AL AP AM BA CE DF ES GO MA MT MS MG PA PB PR PE PI RJ RN RS RO RR SC SP SE TO ].freeze
Class Method Summary collapse
-
.is_valid(params) ⇒ Boolean
(also: valid?)
Checks the structure of a professional council registration number.
Class Method Details
.is_valid(params) ⇒ Boolean Also known as: valid?
Checks the structure of a professional council registration number.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/brazilian-utils/registro-profissional-utils.rb', line 22 def self.is_valid(params) return false unless params.is_a?(Hash) value = params[:value] || params['value'] council = (params[:council] || params['council']).to_s.upcase expected_state = params[:state] || params['state'] return false unless value.is_a?(String) case council when 'OAB', 'CRM' valid_oab_crm?(value, expected_state) when 'CRO' valid_cro?(value, expected_state) when 'CRP' valid_crp?(value) when 'CRC' valid_crc?(value, expected_state) else false end end |