Open sandboxFocus

Class EmailAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid email address. If the target is a nullable type, null strings are accepted and do not throw an exception.

Namespace: Metalama.Patterns.Contracts
Assembly: Metalama.Patterns.Contracts.dll
Syntax
public sealed class EmailAttribute : RegularExpressionBaseAttribute, IAspect<IParameter>, IEligible<IParameter>, IAspect<IFieldOrPropertyOrIndexer>, IEligible<IFieldOrPropertyOrIndexer>, IConditionallyInheritableAspect, IAspect, ICompileTimeSerializable, ITemplateProvider

Constructors

Name Description
EmailAttribute()

Methods

Name Description
GetRegex()

When implemented in a derived class, returns an expression that evaluates to the Regex used for validation.

OnContractViolated(dynamic?, dynamic, ContractContext)

Template method called when the contract validation fails. Override to customize the error behavior.

Extension Methods

See Also