localizing bug record creations
This commit is contained in:
parent
6bde0a51cf
commit
2ed3b7e576
7 changed files with 63 additions and 99 deletions
|
|
@ -4,17 +4,16 @@ namespace Yavsc.Attributes.Validation
|
|||
{
|
||||
public class YaStringLength: YaValidationAttribute
|
||||
{
|
||||
public long MinLen { get; set; } = -1;
|
||||
public long MinimumLength { get; set; } = -1;
|
||||
private long maxLen;
|
||||
public YaStringLength(long maxLen) : base(
|
||||
()=>
|
||||
"BadStringLength")
|
||||
public YaStringLength(long maxLen) : base( ()=> "BadStringLength")
|
||||
{
|
||||
this.maxLen = maxLen;
|
||||
}
|
||||
|
||||
private long excedent=0;
|
||||
private long manquant=0;
|
||||
// hugly ...
|
||||
static long excedent=0;
|
||||
static long manquant=0;
|
||||
|
||||
public override bool IsValid(object value) {
|
||||
|
||||
|
|
@ -24,23 +23,24 @@ namespace Yavsc.Attributes.Validation
|
|||
|
||||
string stringValue = value as string;
|
||||
if (stringValue==null) return false;
|
||||
if (MinLen>=0)
|
||||
if (MinimumLength>=0)
|
||||
{
|
||||
if (stringValue.Length<MinLen)
|
||||
{
|
||||
manquant = MinLen-stringValue.Length;
|
||||
}
|
||||
if (stringValue.Length< MinimumLength)
|
||||
return false;
|
||||
}
|
||||
if (maxLen>=0)
|
||||
{
|
||||
if (stringValue.Length>maxLen) {
|
||||
excedent = stringValue.Length-maxLen;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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