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 | 1e5f122e96ec974b77c2eaab3a9daf7d6c8970f1 (patch) | |
tree | 2a3dc8541097f2823a1b3bea46e5b07b4275b288 /BackEnd/Timeline/Models/Validation/Validator.cs | |
parent | 5bd826d47c30f6e6ac6eded4fefb99f26786c3bc (diff) | |
download | timeline-1e5f122e96ec974b77c2eaab3a9daf7d6c8970f1.tar.gz timeline-1e5f122e96ec974b77c2eaab3a9daf7d6c8970f1.tar.bz2 timeline-1e5f122e96ec974b77c2eaab3a9daf7d6c8970f1.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);
}
}
|