Module: Wavefront::Validators
- Included in:
- CoreApi, Write, Writer::Core
- Defined in:
- lib/wavefront-sdk/validators.rb
Overview
A module of mixins to validate input. The Wavefront documentation lays down restrictions on types and sizes of various inputs, which we will check on the user’s behalf. Most of the information used in this file comes from community.wavefront.com/docs/DOC-1031 Some comes from the Swagger API documentation, some has come directly from Wavefront engineers.
rubocop:disable Metrics/ModuleLength
Instance Method Summary collapse
-
#uuid?(str) ⇒ Bool
Is the given string a UUID? These are used for various item IDs.
-
#wf_account_id?(id) ⇒ Boolean
Ensure the given argument is a valid User or SystemAccount ID.
-
#wf_alert_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront alert ID.
-
#wf_alert_severity?(severity) ⇒ Boolean
Ensure the given argument is a valid alert severity.
-
#wf_apitoken_id?(id) ⇒ Boolean
Ensure the given argument is a valid API token ID.
-
#wf_aws_external_id?(id) ⇒ Boolean
Ensure the given argument is a valid AWS external ID, used in the AWS cloud integration.
-
#wf_cloudintegration_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront cloud integration ID.
-
#wf_dashboard_id?(id) ⇒ Boolean
There doesn’t seem to be a public statement on what’s allowed in a dashboard name.
-
#wf_derivedmetric_id?(id) ⇒ Boolean
Ensure the given argument is a valid derived metric ID.
-
#wf_distribution?(dist) ⇒ Boolean
Validate a distribution description.
-
#wf_distribution_count?(count) ⇒ Boolean
Ensure the given argument is a valid distribution count.
-
#wf_distribution_interval?(interval) ⇒ Boolean
Ensure the given argument is a valid distribution interval.
-
#wf_distribution_values?(vals) ⇒ Boolean
Validate an array of distribution values.
-
#wf_epoch?(timestamp) ⇒ Boolean
Ensure the given argument is a valid epoch timestamp.
-
#wf_event_id?(id) ⇒ Boolean
Ensure the given argument is a valid event ID.
-
#wf_granularity?(granularity) ⇒ Boolean
Ensure the given argument is a valid query granularity.
-
#wf_ingestionpolicy_id?(id) ⇒ Boolean
Ensure the given argument is a valid ingestion policy ID.
-
#wf_integration_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront integration ID.
-
#wf_link_id?(id) ⇒ Boolean
Ensure the given argument is a valid external Link ID.
-
#wf_link_template?(template) ⇒ Boolean
Ensure the given argument is a valid external link template.
-
#wf_maintenance_window_id?(id) ⇒ Boolean
Ensure the given argument is a valid maintenance window ID.
-
#wf_message_id?(id) ⇒ Boolean
Ensure the given argument is a valid message ID.
-
#wf_metric_name?(metric) ⇒ Boolean
Ensure the given argument is a valid Wavefront metric name, or path.
-
#wf_metricspolicy_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront metrics policy ID.
-
#wf_monitoredapplication_id?(id) ⇒ Boolean
Ensure the given argument is a valid monitored application ID.
-
#wf_monitoredcluster_id?(id) ⇒ Boolean
Ensure the given argument is a valid monitored cluster ID.
-
#wf_ms_ts?(timestamp) ⇒ Boolean
Ensure the given argument is a valid millisecond epoch timestamp.
-
#wf_name?(name) ⇒ Boolean
Ensure the given argument is a valid name, for instance for an event.
-
#wf_notificant_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront notificant ID.
-
#wf_permission?(id) ⇒ Boolean
Ensure the given argument is a Wavefront permission.
-
#wf_point?(point) ⇒ Boolean
Validate a point so it conforms to the standard described in community.wavefront.com/docs/DOC-1031.
-
#wf_point_tag?(key, val) ⇒ Boolean
Validate a single point tag, probably on behalf of #wf_point_tags?.
-
#wf_point_tags?(tags) ⇒ Boolean
Ensure a hash of key:value point tags are value.
-
#wf_proxy_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront proxy ID.
-
#wf_role_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront role ID.
-
#wf_sampling_value?(value) ⇒ Boolean
Ensure the given value is a valid sampling rate.
-
#wf_savedsearch_entity?(id) ⇒ Boolean
Ensure the given argument is a valid saved search entity type.
-
#wf_savedsearch_id?(id) ⇒ Boolean
Ensure the given argument is a valid saved search ID.
-
#wf_serviceaccount_id?(id) ⇒ Boolean
Ensure the given argument is a valid service account ID.
-
#wf_source_id?(source) ⇒ Boolean
Ensure the given argument is a valid Wavefront source name.
-
#wf_spansamplingpolicy_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront Span Sampling Policy ID.
-
#wf_string?(str) ⇒ Boolean
Ensure the given argument is a valid string, for a tag name.
-
#wf_tag?(*tags) ⇒ Boolean
Ensure one, or an array, of tags are valid.
-
#wf_trace?(trace) ⇒ Boolean
@.
-
#wf_ts?(timestamp) ⇒ Boolean
Ensure the given argument is a valid timestamp.
-
#wf_user_id?(user) ⇒ Boolean
Ensure the given argument is a valid user.
-
#wf_usergroup_id?(gid) ⇒ Boolean
Ensure the given argument is a valid user group.
-
#wf_value?(value) ⇒ Boolean
Ensure the given argument is a valid Wavefront value.
-
#wf_version?(version) ⇒ Boolean
Ensure the given argument is a valid version number.
-
#wf_webhook_id?(id) ⇒ Boolean
Ensure the given argument is a valid webhook ID.
Instance Method Details
#uuid?(str) ⇒ Bool
Is the given string a UUID? These are used for various item IDs.
23 24 25 |
# File 'lib/wavefront-sdk/validators.rb', line 23 def uuid?(str) str.is_a?(String) && str =~ /([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12})/ end |
#wf_account_id?(id) ⇒ Boolean
Ensure the given argument is a valid User or SystemAccount ID.
590 591 592 593 594 595 596 597 598 |
# File 'lib/wavefront-sdk/validators.rb', line 590 def wf_account_id?(id) true if wf_user_id?(id) rescue Wavefront::Exception::InvalidUserId begin true if wf_serviceaccount_id?(id) rescue Wavefront::Exception::InvalidServiceAccountId raise Wavefront::Exception::InvalidAccountId, id end end |
#wf_alert_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront alert ID. Alerts are identified by the epoch-nanosecond at which they were created.
227 228 229 230 231 232 |
# File 'lib/wavefront-sdk/validators.rb', line 227 def wf_alert_id?(id) id = id.to_s if id.is_a?(Numeric) return true if id.is_a?(String) && id.match(/^\d{13}$/) raise Wavefront::Exception::InvalidAlertId, id end |
#wf_alert_severity?(severity) ⇒ Boolean
Ensure the given argument is a valid alert severity
327 328 329 330 331 |
# File 'lib/wavefront-sdk/validators.rb', line 327 def wf_alert_severity?(severity) return true if %w[INFO SMOKE WARN SEVERE].include?(severity) raise Wavefront::Exception::InvalidAlertSeverity, severity end |
#wf_apitoken_id?(id) ⇒ Boolean
Ensure the given argument is a valid API token ID
540 541 542 543 544 |
# File 'lib/wavefront-sdk/validators.rb', line 540 def wf_apitoken_id?(id) return true if uuid?(id) raise Wavefront::Exception::InvalidApiTokenId, id end |
#wf_aws_external_id?(id) ⇒ Boolean
Ensure the given argument is a valid AWS external ID, used in the AWS cloud integration. not valid
650 651 652 653 654 |
# File 'lib/wavefront-sdk/validators.rb', line 650 def wf_aws_external_id?(id) return true if id.is_a?(String) && id =~ /^[a-z0-9A-Z]{16}$/ raise Wavefront::Exception::InvalidAwsExternalId, id end |
#wf_cloudintegration_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront cloud integration ID
242 243 244 245 246 |
# File 'lib/wavefront-sdk/validators.rb', line 242 def wf_cloudintegration_id?(id) return true if uuid?(id) raise Wavefront::Exception::InvalidCloudIntegrationId, id end |
#wf_dashboard_id?(id) ⇒ Boolean
There doesn’t seem to be a public statement on what’s allowed in a dashboard name. For now I’m going to assume up to 255 word characters.
257 258 259 260 261 |
# File 'lib/wavefront-sdk/validators.rb', line 257 def wf_dashboard_id?(id) return true if id.is_a?(String) && id.size < 256 && id.match(/^[\w-]+$/) raise Wavefront::Exception::InvalidDashboardId, id end |
#wf_derivedmetric_id?(id) ⇒ Boolean
Ensure the given argument is a valid derived metric ID. IDs are the millisecond epoch timestamp at which the derived metric was created.
271 272 273 274 275 276 |
# File 'lib/wavefront-sdk/validators.rb', line 271 def wf_derivedmetric_id?(id) id = id.to_s if id.is_a?(Numeric) return true if id.is_a?(String) && id =~ /^\d{13}$/ raise Wavefront::Exception::InvalidDerivedMetricId, id end |
#wf_distribution?(dist) ⇒ Boolean
Validate a distribution description
460 461 462 463 464 465 466 467 |
# File 'lib/wavefront-sdk/validators.rb', line 460 def wf_distribution?(dist) wf_metric_name?(dist[:path]) wf_distribution_values?(dist[:value]) wf_epoch?(dist[:ts]) if dist[:ts] wf_source_id?(dist[:source]) if dist[:source] (dist[:tags]) if dist[:tags] true end |
#wf_distribution_count?(count) ⇒ Boolean
Ensure the given argument is a valid distribution count.
529 530 531 532 533 |
# File 'lib/wavefront-sdk/validators.rb', line 529 def wf_distribution_count?(count) return true if count.is_a?(Integer) && count.positive? raise Wavefront::Exception::InvalidDistributionCount, count end |
#wf_distribution_interval?(interval) ⇒ Boolean
Ensure the given argument is a valid distribution interval.
518 519 520 521 522 |
# File 'lib/wavefront-sdk/validators.rb', line 518 def wf_distribution_interval?(interval) return true if %i[m h d].include?(interval) raise Wavefront::Exception::InvalidDistributionInterval, interval end |
#wf_distribution_values?(vals) ⇒ Boolean
Validate an array of distribution values
478 479 480 481 482 483 484 |
# File 'lib/wavefront-sdk/validators.rb', line 478 def wf_distribution_values?(vals) vals.each do |times, val| wf_distribution_count?(times) wf_value?(val) end true end |
#wf_epoch?(timestamp) ⇒ Boolean
Ensure the given argument is a valid epoch timestamp. Again, no range checking.
125 126 127 128 129 |
# File 'lib/wavefront-sdk/validators.rb', line 125 def wf_epoch?() return true if .is_a?(Numeric) raise Wavefront::Exception::InvalidTimestamp, end |
#wf_event_id?(id) ⇒ Boolean
Ensure the given argument is a valid event ID. Event IDs are an epoch-millisecond timestamp followed by a : followed by the name of the event.
287 288 289 290 291 |
# File 'lib/wavefront-sdk/validators.rb', line 287 def wf_event_id?(id) return true if id.is_a?(String) && id =~ /^\d{13}:.+/ raise Wavefront::Exception::InvalidEventId, id end |
#wf_granularity?(granularity) ⇒ Boolean
Ensure the given argument is a valid query granularity
352 353 354 355 356 |
# File 'lib/wavefront-sdk/validators.rb', line 352 def wf_granularity?(granularity) return true if %w[d h m s].include?(granularity.to_s) raise Wavefront::Exception::InvalidGranularity, granularity end |
#wf_ingestionpolicy_id?(id) ⇒ Boolean
Ensure the given argument is a valid ingestion policy ID
579 580 581 582 583 |
# File 'lib/wavefront-sdk/validators.rb', line 579 def wf_ingestionpolicy_id?(id) return true if id.is_a?(String) && id =~ /^[a-z0-9\-_]+-\d{13}$/ raise Wavefront::Exception::InvalidIngestionPolicyId, id end |
#wf_integration_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront integration ID. These appear to be lower-case strings.
507 508 509 510 511 |
# File 'lib/wavefront-sdk/validators.rb', line 507 def wf_integration_id?(id) return true if id.is_a?(String) && id =~ /^[a-z0-9]+$/ raise Wavefront::Exception::InvalidIntegrationId, id end |
#wf_link_id?(id) ⇒ Boolean
Ensure the given argument is a valid external Link ID
300 301 302 303 304 |
# File 'lib/wavefront-sdk/validators.rb', line 300 def wf_link_id?(id) return true if id.is_a?(String) && id =~ /^\w{16}$/ raise Wavefront::Exception::InvalidExternalLinkId, id end |
#wf_link_template?(template) ⇒ Boolean
Ensure the given argument is a valid external link template
32 33 34 35 36 37 38 39 |
# File 'lib/wavefront-sdk/validators.rb', line 32 def wf_link_template?(template) if template.is_a?(String) && template.start_with?('http://', 'https://') return true end raise Wavefront::Exception::InvalidLinkTemplate, template end |
#wf_maintenance_window_id?(id) ⇒ Boolean
Ensure the given argument is a valid maintenance window ID. IDs are the millisecond epoch timestamp at which the window was created.
314 315 316 317 318 319 |
# File 'lib/wavefront-sdk/validators.rb', line 314 def wf_maintenance_window_id?(id) id = id.to_s if id.is_a?(Numeric) return true if id.is_a?(String) && id =~ /^\d{13}$/ raise Wavefront::Exception::InvalidMaintenanceWindowId, id end |
#wf_message_id?(id) ⇒ Boolean
Ensure the given argument is a valid message ID
339 340 341 342 343 |
# File 'lib/wavefront-sdk/validators.rb', line 339 def (id) return true if id.is_a?(String) && id =~ /^\w+::\w+$/ raise Wavefront::Exception::InvalidMessageId, id end |
#wf_metric_name?(metric) ⇒ Boolean
Ensure the given argument is a valid Wavefront metric name, or path.
is not valid.
49 50 51 52 53 54 55 56 57 |
# File 'lib/wavefront-sdk/validators.rb', line 49 def wf_metric_name?(metric) if metric.is_a?(String) && metric.size < 1024 && (metric.match(/^#{DELTA}?[\w\-.]+$/o) || metric.match(%r{^"#{DELTA}?[\w\-./,]+"$}o)) return true end raise Wavefront::Exception::InvalidMetricName, metric end |
#wf_metricspolicy_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront metrics policy ID
662 663 664 665 666 |
# File 'lib/wavefront-sdk/validators.rb', line 662 def wf_metricspolicy_id?(id) return true if uuid?(id) raise Wavefront::Exception::InvalidMetricsPolicyId, id end |
#wf_monitoredapplication_id?(id) ⇒ Boolean
Ensure the given argument is a valid monitored application ID
616 617 618 619 620 |
# File 'lib/wavefront-sdk/validators.rb', line 616 def wf_monitoredapplication_id?(id) return true if id.is_a?(String) && id.size < 256 && id =~ /^[a-z0-9\-_]+$/ raise Wavefront::Exception::InvalidMonitoredApplicationId, id end |
#wf_monitoredcluster_id?(id) ⇒ Boolean
Ensure the given argument is a valid monitored cluster ID
605 606 607 608 609 |
# File 'lib/wavefront-sdk/validators.rb', line 605 def wf_monitoredcluster_id?(id) return true if id.is_a?(String) && id.size < 256 && id =~ /^[a-z0-9\-_]+$/ raise Wavefront::Exception::InvalidMonitoredClusterId, id end |
#wf_ms_ts?(timestamp) ⇒ Boolean
Ensure the given argument is a valid millisecond epoch timestamp. We do no checking of the value, because who am I to say that the user doesn’t want to send a point relating to 1ms after the epoch, or a thousand years in the future?
112 113 114 115 116 |
# File 'lib/wavefront-sdk/validators.rb', line 112 def wf_ms_ts?() return true if .is_a?(Numeric) raise Wavefront::Exception::InvalidTimestamp, end |
#wf_name?(name) ⇒ Boolean
Ensure the given argument is a valid name, for instance for an event. Names can contain, AFAIK, word characters.
raise Wavefront::Exception::InvalidName if name is not valid
66 67 68 69 70 |
# File 'lib/wavefront-sdk/validators.rb', line 66 def wf_name?(name) return true if name.is_a?(String) && name.size < 1024 && name =~ /^\w+$/ raise Wavefront::Exception::InvalidName, name end |
#wf_notificant_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront notificant ID.
493 494 495 496 497 |
# File 'lib/wavefront-sdk/validators.rb', line 493 def wf_notificant_id?(id) return true if id.is_a?(String) && id =~ /^\w{16}$/ raise Wavefront::Exception::InvalidNotificantId, id end |
#wf_permission?(id) ⇒ Boolean
Ensure the given argument is a Wavefront permission
562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/wavefront-sdk/validators.rb', line 562 def (id) if %w[alerts_management batch_query_priority embedded_charts dashboard_management derived_metrics_management ingestion events_management external_links_management application_management metrics_management agent_management host_tag_management user_management].include?(id) return true end raise Wavefront::Exception::InvalidPermission, id end |
#wf_point?(point) ⇒ Boolean
Validate a point so it conforms to the standard described in community.wavefront.com/docs/DOC-1031
445 446 447 448 449 450 451 452 |
# File 'lib/wavefront-sdk/validators.rb', line 445 def wf_point?(point) wf_metric_name?(point[:path]) wf_value?(point[:value]) wf_epoch?(point[:ts]) if point[:ts] wf_source_id?(point[:source]) if point[:source] (point[:tags]) if point[:tags] true end |
#wf_point_tag?(key, val) ⇒ Boolean
Validate a single point tag, probably on behalf of #wf_point_tags?
196 197 198 199 200 201 202 203 |
# File 'lib/wavefront-sdk/validators.rb', line 196 def wf_point_tag?(key, val) if key && val && (key.size + val.size < 254) && key =~ /^[\w\-.:]+$/ && val !~ /\\$/ return false end raise Wavefront::Exception::InvalidTag, "#{key}=#{val}" end |
#wf_point_tags?(tags) ⇒ Boolean
Ensure a hash of key:value point tags are value. Not to be confused with source tags.
184 185 186 187 188 |
# File 'lib/wavefront-sdk/validators.rb', line 184 def () raise Wavefront::Exception::InvalidTag unless .is_a?(Hash) .each { |k, v| wf_point_tag?(k, v) } end |
#wf_proxy_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront proxy ID
212 213 214 215 216 |
# File 'lib/wavefront-sdk/validators.rb', line 212 def wf_proxy_id?(id) return true if uuid?(id) raise Wavefront::Exception::InvalidProxyId, id end |
#wf_role_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront role ID
637 638 639 640 641 |
# File 'lib/wavefront-sdk/validators.rb', line 637 def wf_role_id?(id) return true if uuid?(id) raise Wavefront::Exception::InvalidRoleId, id end |
#wf_sampling_value?(value) ⇒ Boolean
Ensure the given value is a valid sampling rate.
626 627 628 629 630 |
# File 'lib/wavefront-sdk/validators.rb', line 626 def wf_sampling_value?(value) return true if value.is_a?(Numeric) && value.between?(0, 0.05) raise Wavefront::Exception::InvalidSamplingValue, value end |
#wf_savedsearch_entity?(id) ⇒ Boolean
Ensure the given argument is a valid saved search entity type.
377 378 379 380 381 382 383 |
# File 'lib/wavefront-sdk/validators.rb', line 377 def wf_savedsearch_entity?(id) return true if %w[DASHBOARD ALERT MAINTENANCE_WINDOW NOTIFICANT EVENT SOURCE EXTERNAL_LINK AGENT CLOUD_INTEGRATION].include?(id) raise Wavefront::Exception::InvalidSavedSearchEntity, id end |
#wf_savedsearch_id?(id) ⇒ Boolean
Ensure the given argument is a valid saved search ID.
364 365 366 367 368 |
# File 'lib/wavefront-sdk/validators.rb', line 364 def wf_savedsearch_id?(id) return true if id.is_a?(String) && id =~ /^\w{8}$/ raise Wavefront::Exception::InvalidSavedSearchId, id end |
#wf_serviceaccount_id?(id) ⇒ Boolean
Ensure the given argument is a valid service account ID
551 552 553 554 555 |
# File 'lib/wavefront-sdk/validators.rb', line 551 def wf_serviceaccount_id?(id) return true if id.is_a?(String) && id.start_with?('sa::') raise Wavefront::Exception::InvalidServiceAccountId, id end |
#wf_source_id?(source) ⇒ Boolean
Ensure the given argument is a valid Wavefront source name
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 |
#wf_spansamplingpolicy_id?(id) ⇒ Boolean
Ensure the given argument is a valid Wavefront Span Sampling Policy ID. So far as I can tell they’re just strings.
675 676 677 678 679 |
# File 'lib/wavefront-sdk/validators.rb', line 675 def wf_spansamplingpolicy_id?(id) return true if id.is_a?(String) raise Wavefront::Exception::InvalidSpanSamplingPolicyId, id end |
#wf_string?(str) ⇒ Boolean
Ensure the given argument is a valid string, for a tag name.
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 |
#wf_tag?(*tags) ⇒ Boolean
Ensure one, or an array, of tags are valid. These tags are used as source tags, or tags for maintenance windows etc. They can contain letters, numbers, -, _ and :, and must be less than 256 characters long
140 141 142 143 144 145 146 147 148 |
# File 'lib/wavefront-sdk/validators.rb', line 140 def wf_tag?(*) Array(*).each do |tag| unless tag.is_a?(String) && tag.size < 255 && tag =~ /^[\w:\-.]+$/ raise Wavefront::Exception::InvalidTag, tag end end true end |
#wf_trace?(trace) ⇒ Boolean
@
470 |
# File 'lib/wavefront-sdk/validators.rb', line 470 def wf_trace?(trace); end |
#wf_ts?(timestamp) ⇒ Boolean
Ensure the given argument is a valid timestamp
97 98 99 100 101 |
# File 'lib/wavefront-sdk/validators.rb', line 97 def wf_ts?() return true if .is_a?(Time) || .is_a?(Date) raise Wavefront::Exception::InvalidTimestamp, end |
#wf_user_id?(user) ⇒ Boolean
Ensure the given argument is a valid user.
407 408 409 410 411 |
# File 'lib/wavefront-sdk/validators.rb', line 407 def wf_user_id?(user) return true if user.is_a?(String) && user.length < 256 && !user.empty? raise Wavefront::Exception::InvalidUserId, user end |
#wf_usergroup_id?(gid) ⇒ Boolean
Ensure the given argument is a valid user group.
419 420 421 422 423 |
# File 'lib/wavefront-sdk/validators.rb', line 419 def wf_usergroup_id?(gid) return true if uuid?(gid) raise Wavefront::Exception::InvalidUserGroupId, gid end |
#wf_value?(value) ⇒ Boolean
Ensure the given argument is a valid Wavefront value. Can be any form of Numeric, including standard notation.
157 158 159 160 161 |
# File 'lib/wavefront-sdk/validators.rb', line 157 def wf_value?(value) return true if value.is_a?(Numeric) raise Wavefront::Exception::InvalidMetricValue, value end |
#wf_version?(version) ⇒ Boolean
Ensure the given argument is a valid version number
169 170 171 172 173 174 |
# File 'lib/wavefront-sdk/validators.rb', line 169 def wf_version?(version) version = version.to_i if version.is_a?(String) && version =~ /^\d+$/ return true if version.is_a?(Integer) && version.positive? raise Wavefront::Exception::InvalidVersion, version end |
#wf_webhook_id?(id) ⇒ Boolean
Ensure the given argument is a valid webhook ID.
431 432 433 434 435 |
# File 'lib/wavefront-sdk/validators.rb', line 431 def wf_webhook_id?(id) return true if id.is_a?(String) && id =~ /^[a-zA-Z0-9]{16}$/ raise Wavefront::Exception::InvalidWebhookId, id end |