require_relative "base"

module Validators
  module FieldValidator
    class FieldType < Base

      def valid?
        @value.is_a?(type)
        #TODO: strip string
        #value.strip! if value.is_a?(String)
      end

      def message
        "Invalid value, it should be a #{type_name}"
      end

      class String < FieldType

        def type
          ::String
        end

        def type_name
          "string"
        end
      end

      class Boolean < FieldType

        def valid?
          @value == true or @value == false
        end

        def type_name
          "boolean"
        end
      end

      class Array < FieldType

        def type
          ::Array
        end

        def type_name
          "array"
        end

        def message
          "Invalid value, it should be an #{type_name}"
        end

      end

      class Hash < FieldType

        def type
          ::Hash
        end

        def type_name
          "object"
        end

        def message
          "Invalid value, it should be an #{type_name}"
        end
      end

    end
  end
end

