Path validation
* invalid path message * its validation attribute
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
/// <summary>
|
||||
/// Valid Remote User Dir Attribute
|
||||
/// </summary>
|
||||
public class ValidRemoteUserFilePathAttribute : ValidationAttribute
|
||||
{
|
||||
public ValidRemoteUserFilePathAttribute()
|
||||
{
|
||||
UseDefaultErrorMessage();
|
||||
}
|
||||
void UseDefaultErrorMessage()
|
||||
{
|
||||
if (ErrorMessageResourceType==null) {
|
||||
ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
|
||||
ErrorMessageResourceName = "InvalidPath";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
if (value == null) return true;
|
||||
var str = (string) value;
|
||||
return str.IsValidYavscPath();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 4.0.30319.42000
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Yavsc.Attributes.Validation {
|
||||
@ -54,5 +54,11 @@ namespace Yavsc.Attributes.Validation {
|
||||
return ResourceManager.GetString("InvalidStringLength", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string InvalidPath {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidPath", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,4 +63,5 @@
|
||||
-->
|
||||
<data name="FieldRequired"><value>Please, fill in this field</value></data>
|
||||
<data name="InvalidStringLength"><value>Invalid string length ({0}..{1})</value></data>
|
||||
<data name="InvalidPath"><value>Invalid file path</value></data>
|
||||
</root>
|
@ -63,5 +63,6 @@
|
||||
-->
|
||||
<data name="FieldRequired"><value>Por favor, preencha este campo</value></data>
|
||||
<data name="InvalidStringLength"><value>comprimento inválido da corrente ({0}..{1})</value></data>
|
||||
<data name="InvalidPath"><value>Camino de arquivo invalido</value></data>
|
||||
|
||||
</root>
|
@ -63,4 +63,5 @@
|
||||
-->
|
||||
<data name="FieldRequired"><value>Veuillez renseigner ce champ</value></data>
|
||||
<data name="InvalidStringLength"><value>Longueur de chaine invalide ({0}..{1})</value></data>
|
||||
<data name="InvalidPath"><value>Chemin de fichier invalide</value></data>
|
||||
</root>
|
Reference in New Issue
Block a user