自定义Metadata验证属性

Posted qiupiaohujie

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自定义Metadata验证属性相关的知识,希望对你有一定的参考价值。

一、定义


using
System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel.DataAnnotations; namespace HJ.BaseMetadata { /// <summary> /// 邮箱验证类 /// </summary> public class EmailAttribute :RegularExpressionAttribute { //验证邮箱 public EmailAttribute():base(@"^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$") { } } }

 

二、调用

[Email(ErrorMessage="邮箱格式不正确")))]
        public string Email { get; set; }

以上是关于自定义Metadata验证属性的主要内容,如果未能解决你的问题,请参考以下文章