in order to use EF7 commands
This commit is contained in:
parent
2a92ad0cac
commit
4b6958e8e9
474 changed files with 316 additions and 181 deletions
|
|
@ -1,58 +0,0 @@
|
|||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
public class YaStringLength: YaValidationAttribute
|
||||
{
|
||||
public long MinLen { get; set; } = -1;
|
||||
private long maxLen;
|
||||
public YaStringLength(long maxLen) : base(
|
||||
()=>string.Format(
|
||||
ResourcesHelpers.GlobalLocalizer["BadStringLength"],
|
||||
maxLen))
|
||||
{
|
||||
this.maxLen = maxLen;
|
||||
}
|
||||
|
||||
private long excedent;
|
||||
private long manquant;
|
||||
|
||||
public override bool IsValid(object value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
string stringValue = value as string;
|
||||
if (stringValue==null) return false;
|
||||
if (MinLen>=0)
|
||||
{
|
||||
if (stringValue.Length<MinLen)
|
||||
{
|
||||
manquant = MinLen-stringValue.Length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (maxLen>=0)
|
||||
{
|
||||
if (stringValue.Length>maxLen) {
|
||||
excedent = stringValue.Length-maxLen;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
if (MinLen<0) {
|
||||
// DetailledMaxStringLength
|
||||
return string.Format(
|
||||
ResourcesHelpers.GlobalLocalizer["DetailledMaxStringLength"],
|
||||
maxLen,
|
||||
excedent);
|
||||
} else
|
||||
return string.Format(
|
||||
ResourcesHelpers.GlobalLocalizer["DetailledMinMaxStringLength"],
|
||||
MinLen,
|
||||
maxLen,
|
||||
manquant,
|
||||
excedent);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue