Class: Etna::Clients::Magma::ProjectValidator
- Inherits:
-
ValidatorBase
- Object
- ValidatorBase
- Etna::Clients::Magma::ProjectValidator
- Defined in:
- lib/etna/clients/magma/workflows/json_validators.rb
Instance Attribute Summary collapse
-
#create_args ⇒ Object
readonly
Returns the value of attribute create_args.
Attributes inherited from ValidatorBase
Instance Method Summary collapse
-
#initialize(**create_args) ⇒ ProjectValidator
constructor
A new instance of ProjectValidator.
- #validate ⇒ Object
- #validate_project_names ⇒ Object
Methods inherited from ValidatorBase
#check_in_set, #check_key, #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.
61 62 63 64 |
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 61 def initialize(**create_args) super() @create_args = create_args end |
Instance Attribute Details
#create_args ⇒ Object (readonly)
Returns the value of attribute create_args.
59 60 61 |
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 59 def create_args @create_args end |
Instance Method Details
#validate ⇒ Object
66 67 68 |
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 66 def validate validate_project_names end |
#validate_project_names ⇒ Object
70 71 72 73 74 75 |
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 70 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 |