Class: Taro::Types::Scalar::StringType
- Inherits:
-
Taro::Types::ScalarType
- Object
- Struct
- BaseType
- Taro::Types::ScalarType
- Taro::Types::Scalar::StringType
- Defined in:
- lib/taro/types/scalar/string_type.rb
Direct Known Subclasses
Constant Summary
Constants included from Taro::Types::Shared::Pattern
Taro::Types::Shared::Pattern::ADVANCED_RUBY_REGEXP_SYNTAX_REGEXP, Taro::Types::Shared::Pattern::NOT_ESCAPED
Constants included from Taro::Types::Shared::OpenAPIFormat
Taro::Types::Shared::OpenAPIFormat::OPENAPI_INTEGER_FORMATS, Taro::Types::Shared::OpenAPIFormat::OPENAPI_NUMBER_FORMATS, Taro::Types::Shared::OpenAPIFormat::OPENAPI_STRING_FORMATS
Constants included from Taro::Types::Shared::OpenAPIType
Taro::Types::Shared::OpenAPIType::OPENAPI_TYPES
Instance Attribute Summary
Attributes inherited from BaseType
Attributes included from Taro::Types::Shared::AdditionalProperties
Attributes included from Taro::Types::Shared::Deprecation
Instance Method Summary collapse
Methods included from Taro::Types::Shared::Pattern
included, #pattern, to_es262, validate, validate_no_advanced_syntax, validate_no_flags, validate_not_empty
Methods included from Taro::Types::Shared::AdditionalProperties
#additional_properties?, #inherited
Methods included from Taro::Types::Shared::DerivedTypes
#define_derived_type, #derived_types, map
Methods included from Taro::Types::Shared::Description
Methods included from Taro::Types::Shared::Equivalence
#equal_properties?, #equivalent?
Methods included from Taro::Types::Shared::Name
Methods included from Taro::Types::Shared::OpenAPIFormat
#inherited, #openapi_format, #openapi_format=
Methods included from Taro::Types::Shared::OpenAPIName
#default_openapi_name, #openapi_name, #openapi_name=
Methods included from Taro::Types::Shared::OpenAPIType
#inherited, #openapi_type, #openapi_type=
Methods included from Taro::Types::Shared::Rendering
#last_render, #last_render=, #render, #used_in_response
Methods included from Taro::Types::Shared::TypeClass
Methods included from Taro::Types::Shared::Errors
#coerce_error_message, #input_error, #response_error
Methods included from Taro::Types::Shared::Caching
#cached_coerce_response, included
Instance Method Details
#coerce_input ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/taro/types/scalar/string_type.rb', line 4 def coerce_input object.instance_of?(String) || input_error('must be a String') pattern.nil? || pattern.match?(object) || input_error("must match pattern #{pattern.inspect}") object end |
#coerce_response ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/taro/types/scalar/string_type.rb', line 13 def coerce_response str = case object when String then object when Symbol then object.to_s else response_error('must be a String or Symbol') end pattern.nil? || pattern.match?(str) || response_error("must match pattern #{pattern.inspect}") str end |