c93207a checks: extend validator with 'alias'

Authored and Committed by qwan 7 years ago
    checks: extend validator with 'alias'
    
    When a property has 'alias' defined, and it's not present in instance,
    if the alias property is present, add the property with value from alias
    property before remove the alias property from instance.
    
    Examples:
    
    with schema:
    {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "title": "Pungi Configuration",
            "type": "object",
            "properties": {
                "release_name": {"type": "string", "alias": "product_name"},
            },
            "required": ["release_name"],
            "additionalProperties": False,
    }
    
    1. config = {"release_name": "dummy product"}:
    
       validate pass, config not changed after validation.
    
    2. config = {"product_name": "dummy product"}:
    
       validate pass, config updated to the following after validation:
    
       config: {"release_name": "dummy product"}
    
    3. config = {"name": "dummy product"}:
    
       validate fail, errror message is "Failed validation in : 'release_name' is a required property",
       and warning message is "WARNING: Unrecognized config option: name."
    
    4. config = {"product_name": "dummy product", "release_name": "dummy product"}
    
       validate fail, error message is "Failed validation in : product_name is an alias of release_name, only one can be used."
    
    Signed-off-by: Qixiang Wan <qwan@redhat.com>
    
        
file modified
+58 -6
file modified
+165 -0