Closed vanderleipinto closed 9 months ago
The Gem 'cpf_cnpj' was added in the Validate CNPJ in Supplier
In the file: app/models/author.rb
class Author < ApplicationRecord has_many :books, dependent: :destroy validates :name, presence: true validates :cpf, presence: true, uniqueness: true validate :cpf, :validate_cpf private def validate_cpf errors.add :cpf, "is invalid" unless CPF.valid?(cpf) end end
Add Gem
The Gem 'cpf_cnpj' was added in the Validate CNPJ in Supplier
Add validates into the Author model including the callback validator 'validate_cnpj':
In the file: app/models/author.rb