This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel.DataAnnotations; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
using System.Web; | |
using System.Xml; | |
using System.Xml.Linq; | |
namespace CommonFunctions.Validation | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] | |
public class DateGreaterThanAttribute : ValidationAttribute, IClientValidatable | |
{ | |
private const string DefaultErrorMessageFormatString = "The {0} field is required."; | |
public string OtherProperty { get; private set; } | |
public DateGreaterThanAttribute(string otherProperty) | |
{ | |
if (string.IsNullOrEmpty(otherProperty)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)] | |
public class AtLeastOneAttribute : ValidationAttribute, IClientValidatable | |
{ | |
public string GroupName { get; private set; } | |
public AtLeastOneAttribute(string groupName) | |
{ | |
GroupName = groupName; | |
} | |
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel.DataAnnotations; | |
using System.Globalization; | |
using System.Linq; | |
using System.Reflection; | |
namespace DataAnnotations | |
{ | |
/// <summary> | |
/// Provides an attribute that compares two properties of a model and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ObservableDataPropertyAttribute : Attribute | |
{ | |
} | |
class DependsOnAttribute : Attribute | |
{ | |
public string Dependency { get; private set; } | |
public DependsOnAttribute(string dependency) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MinDigitsIncluded : ValidationAttribute, IClientValidatable | |
{ | |
private const string DefaultErrorMessage = "{0} must contain at least {1} digits."; | |
public int MinDigits { get; private set; } | |
public MinDigitsIncluded(int minDigits) : base(DefaultErrorMessage) | |
{ | |
MinDigits = minDigits; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.ComponentModel.DataAnnotations; | |
namespace demo_002.Models | |
{ | |
public class ByteInfoAttribute : ValidationAttribute | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel.DataAnnotations; | |
using System.Web; | |
using Orchard; | |
using Patient.Framework.AntiSpam.Services; | |
namespace Patient.Framework.AntiSpam.Attributes { | |
public class RecaptchaAttribute : ValidationAttribute { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class CollectionMinimumLengthAttribute : ValidationAttribute | |
{ | |
private const string ErrorMessageWithMax = "{0} must contain between {1} and {2} item(s)."; | |
private readonly int _minLength; | |
public CollectionMinimumLengthAttribute(int min) | |
{ | |
_minLength = min; | |
MaxLength = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MaxWords : ValidationAttribute | |
{ | |
private int _maxWords; | |
public MaxWords(int maxWords) | |
: base("{0} has too many words") | |
{ | |
_maxWords = maxWords; | |
} |