diff --git a/app/validators/good_small_text_validator.rb b/app/validators/good_small_text_validator.rb new file mode 100644 index 0000000..46fa4e9 --- /dev/null +++ b/app/validators/good_small_text_validator.rb @@ -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 diff --git a/spec/validators/good_small_text_validator_spec.rb b/spec/validators/good_small_text_validator_spec.rb new file mode 100644 index 0000000..a85ae89 --- /dev/null +++ b/spec/validators/good_small_text_validator_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe GoodSmallTextValidator do + pending "add some examples to (or delete) #{__FILE__}" +end