class Hoodoo::Presenters::Text
Public Instance Methods
validate( data, path = '' )
click to toggle source
Check if data is a valid String
and return a Hoodoo::Errors
instance.
Calls superclass method
Hoodoo::Presenters::Field#validate
# File lib/hoodoo/presenters/types/text.rb, line 10 def validate( data, path = '' ) errors = super( data, path ) return errors if errors.has_errors? || ( ! @required && data.nil? ) unless data.is_a?( ::String ) errors.add_error( 'generic.invalid_string', :message => "Field `#{ full_path( path ) }` is an invalid string", :reference => { :field_name => full_path( path ) } ) end errors end