rcritten / freeipa

Forked from freeipa 6 years ago
Clone

aa11e83 Added support of custom field validators

1 file Authored by pvoborni 12 years ago, Committed by simo 12 years ago,
    Added support of custom field validators
    
    Current validation logic supports only validation based on metadata. It can be extended only by overriding field's validation method. This approach requires creating subclasses of field for each different format of desired value. It's inconvenient for cases like adding the same validation logic to two different subclasses of field.
    
    This patch is adding support for creating custom validators.
    
    Validator is an object which contains validation logic. Validation is executed in a validate(value, context) method. This method checks if the value is valid and returns a validation result. Validation result is a simple object which contains valid property and an error message if valid is false.
    
    Field is extended by validators property. It can be set in spec object or later. It should contain instances of validators for the field. Validators are run in field's validation method.
    
    This patch is a prerequisite for:
    https://fedorahosted.org/freeipa/ticket/1466
    
        
file modified
+87 -51