-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APERTA-9087 Coerce and enforce arrays in env vars to reduce complexity
- Loading branch information
Showing
6 changed files
with
46 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require File.dirname(__FILE__) + '/../tahi_env' | ||
|
||
class TahiEnv | ||
class ArrayValidator < ActiveModel::EachValidator | ||
def validate_each(record, attribute, value) | ||
if value | ||
unless YAML::load(value).kind_of?(Array) | ||
message = options[:message] || "Environment Variable: #{attribute} was expected to be set to a string that contains an array of strings, but was set to #{value.inspect}. Allowed array value is in the format \"['server1', 'server2' ,'server3']\"." | ||
record.errors.add :base, message | ||
end | ||
else | ||
message = options[:message] || "Environment Variable: #{attribute} was expected to be set to a string that contains an array of strings, but was not set. Allowed array value is in the format \"['server1', 'server2' ,'server3']\"." | ||
record.errors.add :base, message | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters