The DefaultSchemaProcessor is the default processor class used for processing (validating and pre-processing) schema elements.

Methods
Public Instance methods
process( owner, client, schema, data, path="/" )

Pre-processes the data, possibly in conjuction with the schema. The parameters are identical to those given for validate. The default implementation simply calls Copland::translate_value on the data, using client as the reference value.

The primary purpose of this call is to convert/translate values to their actual types, like "!!service service.name" values.

    # File lib/copland/default-schema-processor.rb, line 91
91:     def process( owner, client, schema, data, path="/" )
92:       return Copland::translate_value( client.owner.registry,
93:         client.owner,
94:         client,
95:         data )
96:     end
validate( owner, client, schema, data, path="/" )

Validates the given data against the given schema. owner is the object associated with the schema, and +client" is the object associated with the data. If path is given, it specifies the path up to the current schema element (for error reporting purposes).

If this method returns, then the validation succeeded. Otherwise, it will raise a ValidationException.

    # File lib/copland/default-schema-processor.rb, line 50
50:     def validate( owner, client, schema, data, path="/" )
51:       return unless schema.definition
52:       schema_keys = schema.definition.keys
53:       data = data.value if data.respond_to?( :type_id )
54:       data_keys = data.keys
55: 
56:       extra_keys = data_keys - schema_keys
57:       unless extra_keys.empty?
58:         validation_error owner, client, path,
59:           "illegal parameter(s) #{extra_keys.inspect}"
60:       end
61: 
62:       schema.definition.each_pair do |key, subschema|
63:         subpath = path + ( path[-1] == ?/ ? "" : "/" ) + key
64: 
65:         if data[key]
66:           validate_type owner,
67:             client,
68:             subschema.type,
69:             data[key],
70:             subpath
71: 
72:           subschema.validate owner,
73:             client,
74:             data[key],
75:             subpath
76: 
77:         elsif subschema.required
78:           validation_error owner, client, path,
79:             "required parameter #{key.inspect} missing"
80:         end
81:       end
82:     end