Skip to content

N_Ifp_Validation

Martin Strecker edited this page Mar 9, 2019 · 6 revisions

Ifp.Validation Namespace

The ifp.Validation namespace contains all the classes for the Ifp.Validation library

Classes

 

Class Description
Public class CollectionValidator(T) Takes one or more validation rules for T and validates IEnumerable(T) against that rules.
Public class RuleBasedValidator(T) A validator that takes a set of objects that implement the IValidationRule(T) interface. Use the ValidationRule(T) class or the ValidationRuleDelegate(T) class as base for the implementation of rules.
Public class SubCollectionValidator(T, U) Validates an object of type T by applying IValidationRule(T)s to a collection that is accessible from T. The rules that get applied are of the underlying type of the collection accessed.
Public class ValidationOutcome Abstract base class for Validation outcomes returned by ValidateObject(T).
Public class ValidationOutcomeWithMessage A base class for ValidationOutcome types with an error message.
Public class ValidationRule(T) The base class for implementing the validation logic. ValidateObject(T) must be implemented with the validation logic.
Public class ValidationRuleDelegate(T) A class that takes a ValidationFunction(T) delegate to perform the validation. This allows to define a validation rule without the need to implement a class that derives from ValidationRule(T).
Public class ValidationSeverity ValidationSeverity is the base class for the description of the Severity of a ValidationOutcome. The severity describes how fatal the result of a validation is. There are four predefined severity levels, but you can also create your own by inheriting from this class. The predefined severity levels are  
Success
The validation was successful (e.g. A required field was filled).
Information
The validation was successful but the user should be informed about problems that were found during the validation (e.g. The birth date you entered indicates that you are under age. You will not be able to use our payed services.)
Warning
The validation found a violation that might be a problem. The user should decide whether he wants to continue or cancel the process (e.g. The item you purchased are overweight. Additional shipping charges apply.)
Error
The validation failed. The error is reported to the user and the process is canceled. (e.g. The email address you entered is invalid.)
Public class ValidationSeverity.ErrorSeverity A default severity. The ValidationSeverity.ErrorSeverity indicates that an object violates a validation rule and the process should be canceled.
Public class ValidationSeverity.InformationSeverity A default severity. The ValidationSeverity.InformationSeverity indicates that an object conforms to a validation rule, but the user should be informed about something.
Public class ValidationSeverity.SuccessSeverity A default severity. The ValidationSeverity.SuccessSeverity indicates that an object conforms to a validation rule.
Public class ValidationSeverity.WarningSeverity A default severity. The ValidationSeverity.WarningSeverity indicates that an object violates a validation rule, but the user should # decide whether the process should be continued or canceled.
Public class ValidationSummary A container for one or more ValidationOutcome objects. The ValidationSummary is usually produced by a RuleBasedValidator(T).
Public class ValidationSummaryBuilder A helper class that allows to build a validation summary step by step. The ValidationSummary can not be changed after construction. The ValidationSummaryBuilder can be used to collect several ValidationOutcome or ValidationSummary objects and append them to a new ValidationSummary.
Public class ValidationSummaryBuilderExtensions Extension methods for the Ifp.Validation library
Public class Validator(T) Base class for validators. Those validators usually don't perform validations on there own but delegate the validation to one or more IValidationRule(T) objects. These IValidationRule(T) objects perform a single isolated validation and the Validator(T) collects the single ValidationOutcome and wrap them in a ValidationSummary.
Public class ValidatorCombiner(T) An IValidator(T) which combines the ValidationSummary of other IValidator(T)s.

Interfaces

 

Interface Description
Public interface IValidationRule(T) Classes that validate other objects should implement this interface. Classes that implement this interface can be combined to rules sets by the RuleBasedValidator(T).
Public interface IValidationSummaryPresentationService Interface for services that can show a ValidationSummary as a dialog to the user. This library does not include an implementation of such a service. A WPF specific implementation can be found in the Ifp.Validation.WPF package.  
Notes to Implementers Notes to Implementers
Implementers of this interface should respect the Severity property by  
Information
Present the outcome to the user and let the user proceed (e.g. by displaying a dialog with an OK button).
Warning
Present the outcome to the user and let the user decide whether to proceed or to cancel. (e.g. by displaying a dialog with an OK and a Cancel button).
Error
Present the outcome to the user and only offer the option to cancel the process (e.g. by displaying a dialog with a disabled OK and an enabled Cancel button).
Public interface IValidator(T) A validator takes an object of type T and performs a validation. The result of the validation is represented by a collection of ValidationOutcome wrapped in a ValidationSummary.

Delegates

 

Delegate Description
Public delegate ValidationFunction(T) The ValidationFunction(T) delegate defines a function that can validate another object. The signature is the same as in ValidateObject(T).

Enumerations

 

Enumeration Description
Public enumeration FailureSeverity An enumeration of predefined failure severities.
 
Clone this wiki locally