Class: Etna::Clients::Magma::ProjectValidator

Inherits:
ValidatorBase show all
Defined in:
lib/etna/clients/magma/workflows/json_validators.rb

Instance Attribute Summary collapse

Attributes inherited from ValidatorBase

#errors

Instance Method Summary collapse

Methods inherited from ValidatorBase

#check_in_set, #check_key, #check_key_empty, #check_valid_name_with_numbers, #format_errors, #model_exists_in_project?, #name_regex_no_numbers, #name_regex_with_numbers, #nil_or_empty?, #valid?, #validate!

Constructor Details

#initialize(**create_args) ⇒ ProjectValidator

Returns a new instance of ProjectValidator.



65
66
67
68
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 65

def initialize(**create_args)
  super()
  @create_args = create_args
end

Instance Attribute Details

#create_argsObject (readonly)

Returns the value of attribute create_args.



63
64
65
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 63

def create_args
  @create_args
end

Instance Method Details

#validateObject



70
71
72
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 70

def validate
  validate_project_names
end

#validate_project_namesObject



74
75
76
77
78
79
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 74

def validate_project_names
  check_key('root project', create_args, :project_name)
  check_key('root project', create_args, :project_name_full)
  name = create_args[:project_name]
  @errors << "Project name #{name} must be snake_case and cannot start with a number or \"pg_\"." unless name =~ name_regex_with_numbers && !name.start_with?('pg_')
end