aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Models/Validation
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd/Timeline/Models/Validation')
-rw-r--r--BackEnd/Timeline/Models/Validation/NameValidator.cs10
-rw-r--r--BackEnd/Timeline/Models/Validation/Resource.Designer.cs312
-rw-r--r--BackEnd/Timeline/Models/Validation/Resource.resx3
-rw-r--r--BackEnd/Timeline/Models/Validation/TimelineNameValidator.cs7
4 files changed, 175 insertions, 157 deletions
diff --git a/BackEnd/Timeline/Models/Validation/NameValidator.cs b/BackEnd/Timeline/Models/Validation/NameValidator.cs
index 2220de6f..c7c18738 100644
--- a/BackEnd/Timeline/Models/Validation/NameValidator.cs
+++ b/BackEnd/Timeline/Models/Validation/NameValidator.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System.Collections.Generic;
+using System.Linq;
using System.Text.RegularExpressions;
namespace Timeline.Models.Validation
@@ -7,10 +8,17 @@ namespace Timeline.Models.Validation
{
private static Regex UniqueIdRegex { get; } = new Regex(@"^[a-zA-Z0-9]{32}$");
+ public List<string> DisallowedNames { get; set; } = new List<string>();
+
public const int MaxLength = 26;
protected override (bool, string) DoValidate(string value)
{
+ if (DisallowedNames.Contains(value))
+ {
+ return (false, Resource.NameDisallowed);
+ }
+
if (value.Length == 0)
{
return (false, Resource.NameCantBeEmpty);
diff --git a/BackEnd/Timeline/Models/Validation/Resource.Designer.cs b/BackEnd/Timeline/Models/Validation/Resource.Designer.cs
index 47ad4248..4f52e047 100644
--- a/BackEnd/Timeline/Models/Validation/Resource.Designer.cs
+++ b/BackEnd/Timeline/Models/Validation/Resource.Designer.cs
@@ -1,153 +1,159 @@
-//------------------------------------------------------------------------------
-// <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>
-//------------------------------------------------------------------------------
-
-namespace Timeline.Models.Validation {
- using System;
-
-
- /// <summary>
- /// A strongly-typed resource class, for looking up localized strings, etc.
- /// </summary>
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resource {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resource() {
- }
-
- /// <summary>
- /// Returns the cached ResourceManager instance used by this class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Models.Validation.Resource", typeof(Resource).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- /// <summary>
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to it can&apos;t be null.
- /// </summary>
- internal static string CantBeNull {
- get {
- return ResourceManager.GetString("CantBeNull", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to name can&apos;t be empty.
- /// </summary>
- internal static string NameCantBeEmpty {
- get {
- return ResourceManager.GetString("NameCantBeEmpty", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to name can&apos;t be longer than {0}.
- /// </summary>
- internal static string NameCantBeLongerThan {
- get {
- return ResourceManager.GetString("NameCantBeLongerThan", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to name can&apos;t has the same pattern of unique id.
- /// </summary>
- internal static string NameCantBeUniqueIdPattern {
- get {
- return ResourceManager.GetString("NameCantBeUniqueIdPattern", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to name can only consists of alphabet, number, &apos;_&apos; and &apos;-&apos; .
- /// </summary>
- internal static string NameInvalidChar {
- get {
- return ResourceManager.GetString("NameInvalidChar", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to nickname can&apos;t be longer than 25.
- /// </summary>
- internal static string NicknameTooLong {
- get {
- return ResourceManager.GetString("NicknameTooLong", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to it is not of type {0}.
- /// </summary>
- internal static string NotOfType {
- get {
- return ResourceManager.GetString("NotOfType", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Failed to create validator instance..
- /// </summary>
- internal static string ValidateWithAttributeExceptionCreateFail {
- get {
- return ResourceManager.GetString("ValidateWithAttributeExceptionCreateFail", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Given type is not a IValidator instance..
- /// </summary>
- internal static string ValidateWithAttributeExceptionNotValidator {
- get {
- return ResourceManager.GetString("ValidateWithAttributeExceptionNotValidator", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to validation passed.
- /// </summary>
- internal static string ValidationPassed {
- get {
- return ResourceManager.GetString("ValidationPassed", resourceCulture);
- }
- }
- }
-}
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Timeline.Models.Validation {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// This class was generated by MSBuild using the GenerateResource task.
+ /// To add or remove a member, edit your .resx file then rerun MSBuild.
+ /// </summary>
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Build.Tasks.StronglyTypedResourceBuilder", "15.1.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resource {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resource() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Models.Validation.Resource", typeof(Resource).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to it can&apos;t be null.
+ /// </summary>
+ internal static string CantBeNull {
+ get {
+ return ResourceManager.GetString("CantBeNull", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to name can&apos;t be empty.
+ /// </summary>
+ internal static string NameCantBeEmpty {
+ get {
+ return ResourceManager.GetString("NameCantBeEmpty", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to name can&apos;t be longer than {0}.
+ /// </summary>
+ internal static string NameCantBeLongerThan {
+ get {
+ return ResourceManager.GetString("NameCantBeLongerThan", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to name can&apos;t has the same pattern of unique id.
+ /// </summary>
+ internal static string NameCantBeUniqueIdPattern {
+ get {
+ return ResourceManager.GetString("NameCantBeUniqueIdPattern", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to this special value is not allowed.
+ /// </summary>
+ internal static string NameDisallowed {
+ get {
+ return ResourceManager.GetString("NameDisallowed", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to name can only consists of alphabet, number, &apos;_&apos; and &apos;-&apos; .
+ /// </summary>
+ internal static string NameInvalidChar {
+ get {
+ return ResourceManager.GetString("NameInvalidChar", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to nickname can&apos;t be longer than 25.
+ /// </summary>
+ internal static string NicknameTooLong {
+ get {
+ return ResourceManager.GetString("NicknameTooLong", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to it is not of type {0}.
+ /// </summary>
+ internal static string NotOfType {
+ get {
+ return ResourceManager.GetString("NotOfType", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Failed to create validator instance..
+ /// </summary>
+ internal static string ValidateWithAttributeExceptionCreateFail {
+ get {
+ return ResourceManager.GetString("ValidateWithAttributeExceptionCreateFail", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Given type is not a IValidator instance..
+ /// </summary>
+ internal static string ValidateWithAttributeExceptionNotValidator {
+ get {
+ return ResourceManager.GetString("ValidateWithAttributeExceptionNotValidator", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to validation passed.
+ /// </summary>
+ internal static string ValidationPassed {
+ get {
+ return ResourceManager.GetString("ValidationPassed", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BackEnd/Timeline/Models/Validation/Resource.resx b/BackEnd/Timeline/Models/Validation/Resource.resx
index 68ba3810..9bec20a5 100644
--- a/BackEnd/Timeline/Models/Validation/Resource.resx
+++ b/BackEnd/Timeline/Models/Validation/Resource.resx
@@ -120,6 +120,9 @@
<data name="CantBeNull" xml:space="preserve">
<value>it can't be null</value>
</data>
+ <data name="NameDisallowed" xml:space="preserve">
+ <value>this special value is not allowed</value>
+ </data>
<data name="NameCantBeEmpty" xml:space="preserve">
<value>name can't be empty</value>
</data>
diff --git a/BackEnd/Timeline/Models/Validation/TimelineNameValidator.cs b/BackEnd/Timeline/Models/Validation/TimelineNameValidator.cs
index f1ab54e8..7cd49fd2 100644
--- a/BackEnd/Timeline/Models/Validation/TimelineNameValidator.cs
+++ b/BackEnd/Timeline/Models/Validation/TimelineNameValidator.cs
@@ -1,5 +1,6 @@
using System;
-
+using System.Collections.Generic;
+
namespace Timeline.Models.Validation
{
public class TimelineNameValidator : NameValidator
@@ -12,8 +13,8 @@ namespace Timeline.Models.Validation
{
public TimelineNameAttribute()
: base(typeof(TimelineNameValidator))
- {
-
+ {
+
}
}
}