My favorites | Sign in
Project Home Downloads Issues Source
Checkout   Browse   Changes  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
´╗┐using System;
using System.Collections.Generic;
using SoftwareMonkeys.SiteStarter.Entities;

namespace SoftwareMonkeys.SiteStarter.Business
{
/// <summary>
/// Defines the interface of all validation strategies.
/// </summary>
public interface IValidateStrategy : IStrategy
{
/// <summary>
/// Validates the provided entity and prepares a list of failures (if applicable).
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
bool Validate(IEntity entity);

/// <summary>
/// Holds a list of property names and validation attributes that have failed validation.
/// </summary>
Dictionary<string, IValidatePropertyAttribute> Failures { get; }

/// <summary>
/// Adds the provided property name and validation attribute type to the list of validation failures.
/// </summary>
/// <param name="propertyName"></param>
/// <param name="attribute"></param>
void AddFailure(string propertyName, IValidatePropertyAttribute attribute);

/// <summary>
/// Retrieves all potential validation failures for the provided entity. This allows potential failures to be checked against validation messages
/// before validation occurs to ensure no messages are missing.
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
Dictionary<string, IValidatePropertyAttribute> GetPotentialFailures(IEntity entity);
}
}

Change log

r1538 by johnrebbeck on Nov 11, 2011   Diff
Added advanced entity/form validation
system which operates (and is enforced) in
the business tier and can be used by the
UI tier
Entity properties can be validated by
adding a RequiredAttribute,
UniqueAttribute, or any other validation
attribute to the appropriate properties
Entity validity can be checked using
entity.IsValid
Validation errors can be retrieved via
entity.Validator.Failures property
Go to: 
Sign in to write a code review

Older revisions

r181 by johnrebbeck on Sep 8, 2010   Diff
Added ActivateStrategy
Added Creator property to
StrategyStateNameValueCollection
Moved all initialization functions
from StrategyStateNameValueCollection
...
All revisions of this file

File info

Size: 1434 bytes, 39 lines
Powered by Google Project Hosting