Add GoodSmallTextValidator
This commit is contained in:
parent
db94693868
commit
2f114c1651
2 changed files with 21 additions and 0 deletions
14
app/validators/good_small_text_validator.rb
Normal file
14
app/validators/good_small_text_validator.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class GoodSmallTextValidator < GoodTextValidator
|
||||||
|
class Validation < Validation
|
||||||
|
MIN = 1
|
||||||
|
MAX = 255
|
||||||
|
|
||||||
|
def perform
|
||||||
|
super
|
||||||
|
error! :too_short, count: MIN if value.to_s.length < MIN
|
||||||
|
error! :too_long, count: MAX if value.to_s.length > MAX
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
7
spec/validators/good_small_text_validator_spec.rb
Normal file
7
spec/validators/good_small_text_validator_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe GoodSmallTextValidator do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Reference in a new issue