mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 05:05:45 +02:00
using validation for only person names
This commit is contained in:
parent
f927ee1cf7
commit
aa7cf1d1b3
3 changed files with 7 additions and 1 deletions
|
@ -32,7 +32,7 @@ class Contact < ApplicationRecord
|
||||||
[\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x.freeze
|
[\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x.freeze
|
||||||
|
|
||||||
validates :name, :email, presence: true
|
validates :name, :email, presence: true
|
||||||
validates :name, format: { without: NAME_REGEXP, message: :invalid }
|
validates :name, format: { without: NAME_REGEXP, message: :invalid }, if: -> { priv? }
|
||||||
|
|
||||||
validates :street, :city, :zip, :country_code, presence: true, if: lambda {
|
validates :street, :city, :zip, :country_code, presence: true, if: lambda {
|
||||||
self.class.address_processing?
|
self.class.address_processing?
|
||||||
|
|
|
@ -14,6 +14,7 @@ en:
|
||||||
too_long_contact_code: "Contact code is too long, max 100 characters"
|
too_long_contact_code: "Contact code is too long, max 100 characters"
|
||||||
name:
|
name:
|
||||||
blank: "Required parameter missing - name"
|
blank: "Required parameter missing - name"
|
||||||
|
invalid: "Name is invalid"
|
||||||
phone:
|
phone:
|
||||||
blank: "Required parameter missing - phone"
|
blank: "Required parameter missing - phone"
|
||||||
invalid: "Phone nr is invalid"
|
invalid: "Phone nr is invalid"
|
||||||
|
|
|
@ -40,6 +40,11 @@ class ContactTest < ActiveJob::TestCase
|
||||||
assert contact.valid?
|
assert contact.valid?
|
||||||
contact.name = '# "¤ #" ¤ "?'
|
contact.name = '# "¤ #" ¤ "?'
|
||||||
assert contact.invalid?
|
assert contact.invalid?
|
||||||
|
|
||||||
|
contact.country_code = 'FI'
|
||||||
|
contact.ident_type = Contact::ORG
|
||||||
|
contact.ident = '1234'
|
||||||
|
assert contact.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validates_code_format
|
def test_validates_code_format
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue