Comments (1)
Example:
/// <summary>
/// Indicates that this property should be a valid email address
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class EMailAttribute : ValidationAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="EMailAttribute"/> class.
/// </summary>
/// <param name="errorMessage">The custom error message, should contain string table item key if 'isMessageFromStringTable' is true.</param>
/// <param name="isMessageFromStringTable">if set to <c>true</c> then indicates that errorMessage is containing string table item key instead of string error message.</param>
public EMailAttribute(string errorMessage = null, bool isMessageFromStringTable = true) : base(errorMessage, isMessageFromStringTable)
{
}
/// <summary>
/// Validates the specified property value.
/// </summary>
/// <param name="value">The object value.</param>
/// <param name="propertyInfo">Information about the property containing this attribute.</param>
/// <param name="resolver">The objects resolver, useful if you need to retrieve some dependencies to perform validation.</param>
public override void Validate(object value, PropertyInfo propertyInfo, IDIResolver resolver)
{
if (!(value is string))
return;
if (StringHelper.ValidateEMail((string)value))
return;
TryThrowCustomOrStringTableException(resolver);
throw new ModelValidationException($"Property '{propertyInfo.Name}' should be an email, actual value: '{value}'");
}
}
from simplify.web.
Related Issues (20)
- Site path cannot be AppDomain.CurrentDomain.BaseDirectory, it is readonly. HOT 4
- Review and update Front End SPA
- Fix code scanning alert - URL redirection from remote source
- Fix code scanning alert - Log entries created from user input
- Changing framework modules via lambda expression in `RegisterSimplifyWeb`
- `Content` controller response should have 'text/plain' type by default
- Fix code scanning alert - Log entries created from user input
- Fix code scanning alert - URL redirection from remote source
- Created response with HTTP 201 status
- Controllers which can get parameters via method arguments instead of RouteParameters HOT 1
- Add Model Validation Attribute For Range Of Numbers HOT 1
- Controller with IList<T> model validation exception
- Enable/disable language switch from cookie
- Set content type "text/plain" for all string responses by default
- npm install in Classic example does not work
- Add package license file
- Add Model Validation Attributes For Min Max
- MinAttribute and MaxAttribute don't work in request view models HOT 2
- RangeAttribute doesn't work in my request view models
- Switchable measurements thru settings (switched off by default)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplify.web.