4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/cf/cli/badge_yaml_validator.rb', line 4
def validate(yaml_path)
errors = []
badge = YAML::load(File.read(yaml_path).strip)
if badge.class == Hash
errors << "Form for the badge is missing" unless badge["form"]
errors << "Name of the badge is missing" unless badge["name"]
errors << "Description for the badge is missing" unless badge["description"]
errors << "Known answers for the badge must be array of hashes" unless badge["known_answers"].class == Array
else
errors << "badge mut be hash"
end
errors
end
|