Don’t use unless
This commit is contained in:
parent
8c73851cec
commit
7c34807f46
90 changed files with 164 additions and 157 deletions
|
@ -5,6 +5,6 @@ class EmailFormatValidator < ActiveModel::Validator
|
|||
|
||||
def validate(record)
|
||||
return if record.email.blank?
|
||||
record.errors[:base] << "Email invalide" unless email_regex.match(record.email)
|
||||
record.errors[:base] << "Email invalide" if !email_regex.match(record.email)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,6 @@ class ProcedurePathFormatValidator < ActiveModel::Validator
|
|||
|
||||
def validate(record)
|
||||
return false if record.path.blank?
|
||||
record.errors[:path] << "Path invalide" unless path_regex.match(record.path)
|
||||
record.errors[:path] << "Path invalide" if !path_regex.match(record.path)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class SiretFormatValidator < ActiveModel::EachValidator
|
||||
def validate_each(record,attribute,value)
|
||||
unless value =~ /^\d{14}$/
|
||||
if !(value =~ /^\d{14}$/)
|
||||
record.errors.add(attribute, :format)
|
||||
end
|
||||
unless value != nil && (luhn_checksum(value) % 10 == 0)
|
||||
if value.nil? || (luhn_checksum(value) % 10 != 0)
|
||||
record.errors.add(attribute, :checksum)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue