From dafde4283785905ef616d421647e5e950d9cae8d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Jul 2026 23:34:32 +0000 Subject: [PATCH] Fix issues #294, #295, #296: annotate removed IV0016, remove dead constants, fix MinLength/MaxLength messages --- src/Immediate.Validations.Analyzers/DiagnosticIds.cs | 2 -- .../Immediate.Validations.Analyzers.md | 4 ++-- .../Localization/ValidatorLocalizer.en.cs | 4 ++-- .../Localization/ValidatorLocalizer.fr.cs | 4 ++-- .../IntegrationTests/InheritanceTests.cs | 2 +- .../Validators/MaxLengthTests.cs | 12 +++++++++++- .../Validators/MinLengthTests.cs | 12 +++++++++++- 7 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/Immediate.Validations.Analyzers/DiagnosticIds.cs b/src/Immediate.Validations.Analyzers/DiagnosticIds.cs index 4fc93fc..ca242f3 100644 --- a/src/Immediate.Validations.Analyzers/DiagnosticIds.cs +++ b/src/Immediate.Validations.Analyzers/DiagnosticIds.cs @@ -11,7 +11,6 @@ public static class DiagnosticIds public const string IV0007ValidateMethodParameterIsIncorrectType = "IV0007"; public const string IV0008ValidatePropertyMustBeRequired = "IV0008"; public const string IV0009ValidatorHasTooManyConstructors = "IV0009"; - public const string IV0019ValidatorIsMissingDefaultMessage = "IV0019"; public const string IV0010ValidatorIsMissingDefaultMessage = "IV0010"; public const string IV0011AssemblyBehaviorsShouldUseValidation = "IV0011"; @@ -20,7 +19,6 @@ public static class DiagnosticIds public const string IV0013IValidationTargetMissing = "IV0013"; public const string IV0014ValidatePropertyIncompatibleType = "IV0014"; public const string IV0015ValidateParameterIncompatibleType = "IV0015"; - public const string IV0016ValidateParameterPropertyIncompatibleType = "IV0016"; public const string IV0017ValidateParameterNameofInvalid = "IV0017"; public const string IV0018ValidateNotNullWhenInvalid = "IV0018"; } diff --git a/src/Immediate.Validations.Analyzers/Immediate.Validations.Analyzers.md b/src/Immediate.Validations.Analyzers/Immediate.Validations.Analyzers.md index 7ab97c3..aba05a6 100644 --- a/src/Immediate.Validations.Analyzers/Immediate.Validations.Analyzers.md +++ b/src/Immediate.Validations.Analyzers/Immediate.Validations.Analyzers.md @@ -176,14 +176,14 @@ A value of invalid type was provided to the validator. | Severity | Warning | | CodeFix | False | -## IV0016: Parameter is incompatible type +## IV0016: Parameter is incompatible type (Removed in 2.3) A `nameof()` reference of invalid type was provided to the validator. | Item | Value | |----------|----------------------| | Category | ImmediateValidations | -| Enabled | True | +| Enabled | False | | Severity | Warning | | CodeFix | False | diff --git a/src/Immediate.Validations.Shared/Localization/ValidatorLocalizer.en.cs b/src/Immediate.Validations.Shared/Localization/ValidatorLocalizer.en.cs index 33cacbd..4f6214e 100644 --- a/src/Immediate.Validations.Shared/Localization/ValidatorLocalizer.en.cs +++ b/src/Immediate.Validations.Shared/Localization/ValidatorLocalizer.en.cs @@ -18,8 +18,8 @@ private static Dictionary En() => [nameof(LessThanAttribute)] = "'{PropertyName}' must be less than '{ComparisonValue}'.", [nameof(LessThanOrEqualAttribute)] = "'{PropertyName}' must be less than or equal to '{ComparisonValue}'.", [nameof(MatchAttribute)] = "'{PropertyName}' is not in the correct format.", - [nameof(MaxLengthAttribute)] = "'{PropertyName}' must be less than {MaxLengthValue} characters.", - [nameof(MinLengthAttribute)] = "'{PropertyName}' must be more than {MinLengthValue} characters.", + [nameof(MaxLengthAttribute)] = "'{PropertyName}' must be at most {MaxLengthValue} characters.", + [nameof(MinLengthAttribute)] = "'{PropertyName}' must be at least {MinLengthValue} characters.", [nameof(NotEmptyAttribute)] = "'{PropertyName}' must not be empty.", [nameof(NotEqualAttribute)] = "'{PropertyName}' must not be equal to '{ComparisonValue}'.", [nameof(NotNullAttribute)] = "'{PropertyName}' must not be null.", diff --git a/src/Immediate.Validations.Shared/Localization/ValidatorLocalizer.fr.cs b/src/Immediate.Validations.Shared/Localization/ValidatorLocalizer.fr.cs index 49bf942..71bf4bc 100644 --- a/src/Immediate.Validations.Shared/Localization/ValidatorLocalizer.fr.cs +++ b/src/Immediate.Validations.Shared/Localization/ValidatorLocalizer.fr.cs @@ -18,8 +18,8 @@ private static Dictionary Fr() => [nameof(LessThanAttribute)] = "'{PropertyName}' doit être inférieur à '{ComparisonValue}'.", [nameof(LessThanOrEqualAttribute)] = "'{PropertyName}' doit être inférieur ou égal à '{ComparisonValue}'.", [nameof(MatchAttribute)] = "'{PropertyName}' n'est pas au bon format.", - [nameof(MaxLengthAttribute)] = "'{PropertyName}' doit être inférieur à {MaxLengthValue} caractères.", - [nameof(MinLengthAttribute)] = "'{PropertyName}' doit être supérieur à {MinLengthValue} caractères.", + [nameof(MaxLengthAttribute)] = "'{PropertyName}' doit avoir au plus {MaxLengthValue} caractères.", + [nameof(MinLengthAttribute)] = "'{PropertyName}' doit avoir au moins {MinLengthValue} caractères.", [nameof(NotEmptyAttribute)] = "'{PropertyName}' ne doit pas être vide.", [nameof(NotEqualAttribute)] = "'{PropertyName}' ne doit pas être égal à '{ComparisonValue}'.", [nameof(NotNullAttribute)] = "'{PropertyName}' ne doit pas être nul.", diff --git a/tests/Immediate.Validations.FunctionalTests/IntegrationTests/InheritanceTests.cs b/tests/Immediate.Validations.FunctionalTests/IntegrationTests/InheritanceTests.cs index 94688e2..364bbe0 100644 --- a/tests/Immediate.Validations.FunctionalTests/IntegrationTests/InheritanceTests.cs +++ b/tests/Immediate.Validations.FunctionalTests/IntegrationTests/InheritanceTests.cs @@ -54,7 +54,7 @@ public void ShortIdHasErrors() new() { PropertyName = "Id", - ErrorMessage = "'Id' must be more than 4 characters.", + ErrorMessage = "'Id' must be at least 4 characters.", }, ], errors diff --git a/tests/Immediate.Validations.FunctionalTests/Validators/MaxLengthTests.cs b/tests/Immediate.Validations.FunctionalTests/Validators/MaxLengthTests.cs index 098ecef..1935bdd 100644 --- a/tests/Immediate.Validations.FunctionalTests/Validators/MaxLengthTests.cs +++ b/tests/Immediate.Validations.FunctionalTests/Validators/MaxLengthTests.cs @@ -21,6 +21,16 @@ public void MaxLengthWhenShort() Assert.Empty(errors); } + [Fact] + public void MaxLengthWhenExactBoundary() + { + var instance = new StringRecord { StringValue = new string('a', 30) }; + + var errors = StringRecord.Validate(instance); + + Assert.Empty(errors); + } + [Fact] public void MaxLengthWhenLong() { @@ -33,7 +43,7 @@ public void MaxLengthWhenLong() new() { PropertyName = nameof(StringRecord.StringValue), - ErrorMessage = "'String Value' must be less than 30 characters.", + ErrorMessage = "'String Value' must be at most 30 characters.", }, ], errors diff --git a/tests/Immediate.Validations.FunctionalTests/Validators/MinLengthTests.cs b/tests/Immediate.Validations.FunctionalTests/Validators/MinLengthTests.cs index 319043a..5e51785 100644 --- a/tests/Immediate.Validations.FunctionalTests/Validators/MinLengthTests.cs +++ b/tests/Immediate.Validations.FunctionalTests/Validators/MinLengthTests.cs @@ -21,6 +21,16 @@ public void MinLengthWhenShort() Assert.Empty(errors); } + [Fact] + public void MinLengthWhenExactBoundary() + { + var instance = new StringRecord { StringValue = new string('a', 30) }; + + var errors = StringRecord.Validate(instance); + + Assert.Empty(errors); + } + [Fact] public void MinLengthWhenLong() { @@ -33,7 +43,7 @@ public void MinLengthWhenLong() new() { PropertyName = nameof(StringRecord.StringValue), - ErrorMessage = "'String Value' must be more than 30 characters.", + ErrorMessage = "'String Value' must be at least 30 characters.", }, ], errors