This file contains hidden or 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; | |
| namespace Asset.Web.Filters | |
| { | |
| /// <summary> | |
| /// Checks if an enumeration is valid. Will return true if no value is specified. | |
| /// </summary> | |
| public class EnumAttribute: ValidationAttribute |
This file contains hidden or 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.Linq; | |
| using System.Web; | |
| namespace Areas.Cms.Validation | |
| { | |
| public class ValidateExtensionAttribute : ValidationAttribute | |
| { | |
| public override bool IsValid(object value) | |
| { | |
| HttpPostedFileBase file = value as HttpPostedFileBase; |
This file contains hidden or 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.CodeDom; | |
| using System.ComponentModel.DataAnnotations; | |
| using System.Web.Http; | |
| using DataValidation; | |
| using Microsoft.VisualStudio.TestTools.UnitTesting; | |
| namespace Tests.Validation | |
| { | |
| [TestClass] | |
| public class OneOfIsRequiredTests |
This file contains hidden or 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; | |
| namespace Springsteen.WebApi.Contract | |
| { | |
| public class RequiredUnlessSeqNumAttribute : ValidationAttribute | |
| { | |
| protected override ValidationResult IsValid(object value, ValidationContext validationContext) | |
| { | |
| int seqNum; |
This file contains hidden or 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
| /// <summary> | |
| /// This is used on mostly checkboxes that ensure that they are ticked such as terms and conditions. | |
| /// </summary> | |
| public class MustBeTrueAttribute : ValidationAttribute | |
| { | |
| public override bool IsValid(object value) | |
| { | |
| if (value == null) return false; | |
| if (value.GetType() != typeof(bool)) return false; |
This file contains hidden or 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 PasswordsMustMatchAttribute : ValidationAttribute | |
| { | |
| protected override ValidationResult IsValid( | |
| object value, ValidationContext validationContext) | |
| { | |
| var model = validationContext.ObjectInstance as Person; | |
| if (model.Password == model.PasswordConfirm) | |
| { | |
| return ValidationResult.Success; | |
| } |
This file contains hidden or 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 DataValidation; | |
| using Microsoft.VisualStudio.TestTools.UnitTesting; | |
| namespace CHR.API.Provisioning.ATT.Web.Tests | |
| { | |
| [TestClass] | |
| public class OneOfValidationTests | |
| { |
This file contains hidden or 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 MustBeEmptyAttribute : ValidationAttribute | |
| { | |
| public override bool IsValid(object value) | |
| { | |
| if (value == null) | |
| { | |
| return true; | |
| } | |
| if (value is string) | |
| { |
This file contains hidden or 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 DataValidation; | |
| using Microsoft.VisualStudio.TestTools.UnitTesting; | |
| namespace CHR.API.Provisioning.ATT.Web.Tests | |
| { | |
| [TestClass] | |
| public class OneOfValidationTests | |
| { | |
| [TestMethod] | |
| public void OneOfAttribute_Should_Validate_Test() |
This file contains hidden or 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.Net; | |
| using System.Web.Http.Filters; | |
| namespace ServiceFabric.WebApi.Filters | |
| { | |
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)] | |
| public class ResourceNotFoundAttribute : ActionFilterAttribute | |
| { | |
| public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) |