alphagov/vcloud-core — pull request #50 by dcarley (2014-05-19 10:08:11+00:00)
Title: [#70452106] Support schema deprecations in ConfigValidator

The renaming of `catalog_item` to `vapp_template` in vcloud-launcher has
exposed the need for parameter deprecations in schemas. Because one or the
other is required, but not both, and a warning should be raised if the old
param is provided.

This is only supported in the simplest case where the two parameters exist
at the same nesting level in the schema. We omit the `required` checking for
deprecated params (if they're not provided) because we don't want to
complain about both params.

---

It doesn't currently check deprecations resolve if data isn't provided for a given level in a hash. Here's a failing test as an example. Do we think that's a problem?
```ruby
it "should raise exception if deprecator does not exist in schema and no data is provided for that hash" do
data = { bogus: "blah" }
schema = {
type: "Hash",
internals: {
nested: { type: 'hash', internals: {
name: { type: 'string', deprecated_by: 'full_name' },
full_name: { type: 'string', required: true },
}},
bogus: { type: 'string' },
}
}
expect {
ConfigValidator.validate(:base, data, schema)
}.to raise_error("name: deprecated_by target 'full_name' not found in schema")
end
```