Localization
This commit is contained in:
parent
89cf80e707
commit
313ba449e7
29 changed files with 1140 additions and 65 deletions
|
|
@ -2,14 +2,31 @@ using System;
|
|||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
public class YaStringLength: YaValidationAttribute
|
||||
public partial class YaStringLength: YaValidationAttribute
|
||||
{
|
||||
public long MinimumLength { get; set; } = 0;
|
||||
private long maxLen;
|
||||
public YaStringLength(long maxLen) : base( ()=> "BadStringLength")
|
||||
{
|
||||
this.maxLen = maxLen;
|
||||
UseDefaultErrorMessage();
|
||||
}
|
||||
public YaStringLength(long minLen, long maxLen) : base( ()=> "BadStringLength")
|
||||
{
|
||||
this.maxLen = maxLen;
|
||||
this.MinimumLength=minLen;
|
||||
UseDefaultErrorMessage();
|
||||
|
||||
}
|
||||
void UseDefaultErrorMessage()
|
||||
{
|
||||
if (ErrorMessageResourceType==null) {
|
||||
ErrorMessageResourceType = typeof(YaStringLength);
|
||||
ErrorMessageResourceName = "InvalidStringLength";
|
||||
}
|
||||
}
|
||||
|
||||
string errorMessageResourceName;
|
||||
|
||||
public override bool IsValid(object value) {
|
||||
|
||||
|
|
@ -36,6 +53,7 @@ namespace Yavsc.Attributes.Validation
|
|||
}
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
|
||||
var temp = base.FormatErrorMessage(name);
|
||||
return string.Format(temp, MinimumLength, maxLen);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue