aspnetcore/test/Microsoft.AspNetCore.Mvc.In.../CompanyNameAttribute.cs

22 lines
719 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.AspNetCore.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;
}
}
}