aspnetcore/test/Microsoft.AspNet.Mvc.Integr.../CompanyNameAttribute.cs

22 lines
718 B
C#

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.ComponentModel.DataAnnotations;
namespace Microsoft.AspNet.Mvc.IntegrationTests
{
public class CompanyNameAttribute : ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
var valueString = value as string;
if (string.IsNullOrEmpty(valueString))
{
return new ValidationResult("CompanyName cannot be null or empty.");
}
return null;
}
}
}