def validate_field(field, allowed_keys, allowed_types):
    """Validate field is allowed and valid."""
    for key, value in field.items():
        if key not in allowed_keys:
            raise exceptions.ParametersFieldError(key, "property")
        if key == defs.TYPE:
            if value not in allowed_types:
                raise exceptions.ParametersFieldError(value, key)
        if key == defs.VALUE:
            if not is_valid_field_name(value):
                raise exceptions.ParametersFieldError(value, "field name")
def validate_field ( field , allowed_keys , allowed_types ) : for key , value in field . items ( ) : if key not in allowed_keys : raise exceptions . ParametersFieldError ( key , "property" ) if key == defs . TYPE : if value not in allowed_types : raise exceptions . ParametersFieldError ( value , key ) if key == defs . VALUE : if not is_valid_field_name ( value ) : raise exceptions . ParametersFieldError ( value , "field name" )
Validate field is allowed and valid.