diff options
author | crupest <crupest@outlook.com> | 2021-04-30 18:09:01 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-04-30 18:09:01 +0800 |
commit | c2998e5833da46bbe5539bb4ce49fb3f10867a1d (patch) | |
tree | 334db84212be85520fd4d1b5a7c17595c78b8318 /BackEnd/Timeline/Models/Validation/Validator.cs | |
parent | e536121d97610af09d6bf4a51a875b0f7d50f702 (diff) | |
download | timeline-c2998e5833da46bbe5539bb4ce49fb3f10867a1d.tar.gz timeline-c2998e5833da46bbe5539bb4ce49fb3f10867a1d.tar.bz2 timeline-c2998e5833da46bbe5539bb4ce49fb3f10867a1d.zip |
refactor: ...
Diffstat (limited to 'BackEnd/Timeline/Models/Validation/Validator.cs')
-rw-r--r-- | BackEnd/Timeline/Models/Validation/Validator.cs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/BackEnd/Timeline/Models/Validation/Validator.cs b/BackEnd/Timeline/Models/Validation/Validator.cs index ec6cc0af..d334960e 100644 --- a/BackEnd/Timeline/Models/Validation/Validator.cs +++ b/BackEnd/Timeline/Models/Validation/Validator.cs @@ -1,6 +1,5 @@ using System;
using System.ComponentModel.DataAnnotations;
-using static Timeline.Resources.Models.Validation.Validator;
namespace Timeline.Models.Validation
{
@@ -56,7 +55,7 @@ namespace Timeline.Models.Validation if (PermitNull)
return (true, GetSuccessMessage());
else
- return (false, ValidatorMessageNull);
+ return (false, Resource.CantBeNull);
}
if (value is T v)
@@ -65,11 +64,11 @@ namespace Timeline.Models.Validation }
else
{
- return (false, ValidatorMessageBadType);
+ return (false, string.Format(Resource.NotOfType, typeof(T).Name));
}
}
- protected static string GetSuccessMessage() => ValidatorMessageSuccess;
+ protected static string GetSuccessMessage() => Resource.ValidationPassed;
protected abstract (bool, string) DoValidate(T value);
}
@@ -99,7 +98,7 @@ namespace Timeline.Models.Validation throw new ArgumentNullException(nameof(validatorType));
if (!typeof(IValidator).IsAssignableFrom(validatorType))
- throw new ArgumentException(ValidateWithAttributeExceptionNotValidator, nameof(validatorType));
+ throw new ArgumentException(Resource.ValidateWithAttributeExceptionNotValidator, nameof(validatorType));
try
{
@@ -107,7 +106,7 @@ namespace Timeline.Models.Validation }
catch (Exception e)
{
- throw new ArgumentException(ValidateWithAttributeExceptionCreateFail, e);
+ throw new ArgumentException(Resource.ValidateWithAttributeExceptionCreateFail, e);
}
}
|