Skip to content

Commit

Permalink
[ODS-6380] POST to a Descriptor is allowing empty spaces in the requi…
Browse files Browse the repository at this point in the history
…red fields (#1123)
  • Loading branch information
gmcelhanon authored Aug 23, 2024
1 parent 36421bc commit fa6b3e3
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override ValidationResult IsValid(object value, ValidationContext vali
{
if (value is string s)
{
if (s.Equals(string.Empty))
if (s.Equals(string.Empty) || IsWhiteSpace(s))
{
return BuildValidationResult($"{validationContext.DisplayName} is required and should not be left empty.");
}
Expand Down Expand Up @@ -61,5 +61,15 @@ ValidationResult BuildValidationResult(string message)
new[] { validationContext.MemberNamePath() });
}
}

private bool IsWhiteSpace(string value)
{
for (int i = 0; i < value.Length; i++)
{
if (!char.IsWhiteSpace(value[i])) return false;
}

return true;
}
}
}
Loading

0 comments on commit fa6b3e3

Please sign in to comment.