Class: CC::Analyzer::MeasurementValidations::NameValidation

Inherits:
Validation
  • Object
show all
Defined in:
lib/cc/analyzer/measurement_validations/name_validation.rb

Constant Summary collapse

REGEX =
/^[A-Za-z0-9_\.\-]+$/

Instance Method Summary collapse

Methods inherited from Validation

#initialize

Constructor Details

This class inherits a constructor from CC::Analyzer::MeasurementValidations::Validation

Instance Method Details

#messageObject



11
12
13
# File 'lib/cc/analyzer/measurement_validations/name_validation.rb', line 11

def message
  "Name must be present and contain only letters, numbers, periods, hyphens, and underscores"
end

#valid?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/cc/analyzer/measurement_validations/name_validation.rb', line 7

def valid?
  name&.is_a?(String) && REGEX.match?(name)
end