Using YaStringLength and YaRequired
This commit is contained in:
@ -14,10 +14,12 @@ namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
ErrorMessage = msg;
|
||||
}
|
||||
public YaRequiredAttribute () : base("RequiredField")
|
||||
public YaRequiredAttribute () : base("Required Field")
|
||||
{
|
||||
|
||||
ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
|
||||
ErrorMessageResourceName = "FieldRequired";
|
||||
}
|
||||
|
||||
public override bool IsValid(object value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
|
@ -20,7 +20,7 @@ namespace Yavsc.Attributes.Validation
|
||||
void UseDefaultErrorMessage()
|
||||
{
|
||||
if (ErrorMessageResourceType==null) {
|
||||
ErrorMessageResourceType = typeof(YaStringLength);
|
||||
ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
|
||||
ErrorMessageResourceName = "InvalidStringLength";
|
||||
}
|
||||
}
|
||||
|
@ -12,14 +12,24 @@ namespace Yavsc.Helpers
|
||||
public static string UserBillsDirName { set; get; }
|
||||
public static string UserFilesDirName { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is Valid this Path?
|
||||
/// Return true when given value is a valid user file sub-path,
|
||||
/// regarding chars used to specify it.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to validate</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValidYavscPath(this string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return true;
|
||||
// disallow full path specification
|
||||
if (path[0]==Path.DirectorySeparatorChar) return false;
|
||||
foreach (var name in path.Split(Path.DirectorySeparatorChar))
|
||||
{
|
||||
if (!IsValidDirectoryName(name) || name.Equals("..") || name.Equals("."))
|
||||
return false;
|
||||
}
|
||||
// disallow trailling slash
|
||||
if (path[path.Length-1]==RemoteDirectorySeparator) return false;
|
||||
return true;
|
||||
}
|
||||
|
7
src/Yavsc.Abstract/FileSystem/FsOperationInfo.cs
Normal file
7
src/Yavsc.Abstract/FileSystem/FsOperationInfo.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Yavsc.Helpers
|
||||
{
|
||||
public class FsOperationInfo {
|
||||
public bool Done { get; set; } = false;
|
||||
public string Error { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Yavsc.ViewModels
|
||||
{
|
||||
@ -11,7 +11,6 @@ namespace Yavsc.ViewModels
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public DateTime LastModified { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Yavsc.Attributes.Validation;
|
||||
|
||||
namespace Yavsc.Models.Identity
|
||||
{
|
||||
public class BlackListedUserName : IWatchedUserName {
|
||||
|
||||
[Key]
|
||||
[StringLength(1024)]
|
||||
[YaStringLength(1024)]
|
||||
public string Name { get; set;}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Yavsc.Attributes.Validation;
|
||||
|
||||
namespace Yavsc.Models.Identity
|
||||
{
|
||||
public class ReservedUserName : IWatchedUserName {
|
||||
|
||||
[Key]
|
||||
[StringLength(1024)]
|
||||
[YaStringLength(1024)]
|
||||
public string Name { get; set;}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
SOURCE_DIR=$(HOME)/workspace/yavsc
|
||||
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/build/make
|
||||
BASERESX=Resources/Yavsc.Attributes.Validation.YaStringLength.resx
|
||||
BASERESX=Resources/Yavsc.Attributes.Validation.Resources.resx
|
||||
BASERESXGEN=$(BASERESX:.resx=.Designer.cs)
|
||||
include $(MAKEFILE_DIR)/versioning.mk
|
||||
include $(MAKEFILE_DIR)/dnx.mk
|
||||
|
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<!--
|
||||
route name for the api controller used to tag the 'BlogPost' entity
|
||||
-->
|
||||
<data name="FieldRequired"><value>Por favor, preencha este campo</value></data>
|
||||
<data name="InvalidStringLength"><value>comprimento inválido da corrente ({0}..{1})</value></data>
|
||||
|
||||
</root>
|
@ -1,12 +1,12 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
namespace Yavsc.Attributes.Validation {
|
||||
using System;
|
||||
@ -16,7 +16,7 @@ namespace Yavsc.Attributes.Validation {
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public partial class YaStringLength {
|
||||
public partial class Resources {
|
||||
|
||||
private static System.Resources.ResourceManager resourceMan;
|
||||
|
||||
@ -26,7 +26,7 @@ namespace Yavsc.Attributes.Validation {
|
||||
public static System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.Equals(null, resourceMan)) {
|
||||
System.Resources.ResourceManager temp = new System.Resources.ResourceManager(("Yavsc.Abstract.Resources." + "Yavsc.Attributes.Validation.YaStringLength"), typeof(YaStringLength).GetTypeInfo().Assembly);
|
||||
System.Resources.ResourceManager temp = new System.Resources.ResourceManager(("Yavsc.Abstract.Resources." + "Yavsc.Attributes.Validation.Resources"), typeof(Resources).GetTypeInfo().Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
@ -43,6 +43,12 @@ namespace Yavsc.Attributes.Validation {
|
||||
}
|
||||
}
|
||||
|
||||
public static string FieldRequired {
|
||||
get {
|
||||
return ResourceManager.GetString("FieldRequired", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string InvalidStringLength {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidStringLength", resourceCulture);
|
@ -61,6 +61,6 @@
|
||||
<!--
|
||||
route name for the api controller used to tag the 'BlogPost' entity
|
||||
-->
|
||||
<data name="FieldRequired"><value>Please, fill in this field</value></data>
|
||||
<data name="InvalidStringLength"><value>Invalid string length ({0}..{1})</value></data>
|
||||
|
||||
</root>
|
@ -61,6 +61,6 @@
|
||||
<!--
|
||||
route name for the api controller used to tag the 'BlogPost' entity
|
||||
-->
|
||||
<data name="FieldRequired"><value>Veuillez renseigner ce champ</value></data>
|
||||
<data name="InvalidStringLength"><value>Longueur de chaine invalide ({0}..{1})</value></data>
|
||||
|
||||
</root>
|
Reference in New Issue
Block a user