Method: Wavefront::Validators#wf_string?

Defined in:
lib/wavefront-sdk/validators.rb

#wf_string?(str) ⇒ Boolean

Ensure the given argument is a valid string, for a tag name.

Parameters:

  • str (String)

    the string name to validate

Returns:

  • (Boolean)

    True if the string is valid

Raises:

  • Wavefront::Exception::InvalidString if string is not valid.



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/wavefront-sdk/validators.rb', line 78

def wf_string?(str)
  #
  # Only allows PCRE "word" characters, spaces, full-stops and
  # commas in tags and descriptions. This might be too restrictive,
  # but if it is, this is the only place we need to change it.
  #
  if str.is_a?(String) && str.size < 1024 && str =~ /^[-\w .,]*$/
    return true
  end

  raise Wavefront::Exception::InvalidString, str
end