8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/cfn-model/validator/cloudformation_validator.rb', line 8
def validate(cloudformation_string)
if json_text?(cloudformation_string)
raise ParserError.new('Invalid JSON!') unless valid_json?(cloudformation_string)
end
schema = SchemaGenerator.new.generate cloudformation_string
validator = Kwalify::Validator.new(schema)
validator.validate(YAML.safe_load(cloudformation_string, permitted_classes: [Date, Symbol]))
rescue ArgumentError, IOError, NameError => e
raise ParserError, e.inspect
end
|