Method: Wavefront::Validators#wf_source_id?

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

#wf_source_id?(source) ⇒ Boolean

Ensure the given argument is a valid Wavefront source name

Parameters:

  • source (String)

    the source name to validate

Returns:

  • (Boolean)

    True if the source name is valid

Raises:

  • Wavefront::Exception::InvalidSourceId if the source name is not valid



392
393
394
395
396
397
398
399
# File 'lib/wavefront-sdk/validators.rb', line 392

def wf_source_id?(source)
  if source.is_a?(String) && source.match(/^[\w.-]+$/) &&
     source.size < 1024
    return true
  end

  raise Wavefront::Exception::InvalidSourceId, source
end