mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Validate iban
This commit is contained in:
parent
ca317ace45
commit
da191e14e6
4 changed files with 18 additions and 1 deletions
|
@ -3,6 +3,7 @@ module Admin
|
|||
load_and_authorize_resource
|
||||
before_action :set_registrar, only: [:show, :edit, :update, :destroy]
|
||||
helper_method :registry_vat_rate
|
||||
helper_method :iban_max_length
|
||||
|
||||
def index
|
||||
@q = Registrar.joins(:accounts).ordered.search(params[:q])
|
||||
|
@ -80,5 +81,9 @@ module Admin
|
|||
def registry_vat_rate
|
||||
Registry.current.vat_rate
|
||||
end
|
||||
|
||||
def iban_max_length
|
||||
Iban.max_length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
5
app/models/iban.rb
Normal file
5
app/models/iban.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class Iban
|
||||
def self.max_length
|
||||
34
|
||||
end
|
||||
end
|
|
@ -73,7 +73,7 @@
|
|||
<%= f.label :iban %>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<%= f.text_field :iban, class: 'form-control' %>
|
||||
<%= f.text_field :iban, maxlength: iban_max_length, class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
7
test/models/iban_test.rb
Normal file
7
test/models/iban_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class IbanTest < ActiveSupport::TestCase
|
||||
def test_returns_max_length
|
||||
assert_equal 34, Iban.max_length
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue