Skip to content

Commit

Permalink
Fix behavioural changes in EmptyValidator/NotEmptyValidator introduce…
Browse files Browse the repository at this point in the history
…d in previous release
  • Loading branch information
JeremySkinner committed Nov 22, 2023
1 parent feeb5ae commit 513eaa1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
11.8.1 - 22 Nov 2023
Fix unintentional behavioural changes in introduced in the previous release as part of #2158

11.8.0 - 19 Oct 2023
Added AbstractValidator.OnRuleAdded to allow customization of rule instances after creation (#2114)
Fix Serbian translation of LengthValidator (#2147)
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>11.8.0</VersionPrefix>
<VersionPrefix>11.8.1</VersionPrefix>
<VersionSuffix></VersionSuffix>
<!-- Use CI build number as version suffix (if defined) -->
<!--<VersionSuffix Condition="'$(GITHUB_RUN_NUMBER)'!=''">ci-$(GITHUB_RUN_NUMBER)</VersionSuffix>-->
Expand Down
12 changes: 6 additions & 6 deletions src/FluentValidation/Validators/EmptyValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ public class EmptyValidator<T,TProperty> : PropertyValidator<T,TProperty> {
return true;
}

if (value is string s) {
return string.IsNullOrWhiteSpace(s);
if (value is string s && string.IsNullOrWhiteSpace(s)) {
return true;
}

if (value is ICollection col) {
return col.Count == 0;
if (value is ICollection col && col.Count == 0) {
return true;
}

if (value is IEnumerable e) {
return !e.GetEnumerator().MoveNext();
if (value is IEnumerable e && !e.GetEnumerator().MoveNext()) {
return true;
}

return EqualityComparer<TProperty>.Default.Equals(value, default);
Expand Down
12 changes: 6 additions & 6 deletions src/FluentValidation/Validators/NotEmptyValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public class NotEmptyValidator<T,TProperty> : PropertyValidator<T, TProperty>, I
return false;
}

if (value is string s) {
return !string.IsNullOrWhiteSpace(s);
if (value is string s && string.IsNullOrWhiteSpace(s)) {
return false;
}

if (value is ICollection col) {
return col.Count > 0;
if (value is ICollection col && col.Count == 0) {
return false;
}

if (value is IEnumerable e) {
return e.GetEnumerator().MoveNext();
if (value is IEnumerable e && !e.GetEnumerator().MoveNext()) {
return false;
}

return !EqualityComparer<TProperty>.Default.Equals(value, default);
Expand Down

0 comments on commit 513eaa1

Please sign in to comment.