Don’t use unless

This commit is contained in:
gregoirenovel 2018-01-11 19:04:39 +01:00
parent 8c73851cec
commit 7c34807f46
90 changed files with 164 additions and 157 deletions

View file

@ -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