Skip to content

Commit b759975

Browse files
erwan-jolyclaude
andauthored
fix: IsValid accepts empty strings for non-nullable string fields (20.0.3) (#461)
PacketBase.IsValid constructed RequiredAttribute with default AllowEmptyStrings=false, so a non-nullable string property with an empty value (e.g. NsTestPacket.LeadingBlank = "" that models the literal double-space token) failed validation with "The <Type> field is required.". Empty tokens are legal on the wire; allow them. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 41cf996 commit b759975

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/NosCore.Packets/NosCore.Packets.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<RepositoryUrl>https://github.com/NosCoreIO/NosCore.Packets.git</RepositoryUrl>
1313
<PackageIconUrl></PackageIconUrl>
1414
<PackageTags>nostale, noscore, chickenapi, nostale private server source, nostale emulator</PackageTags>
15-
<Version>20.0.2</Version>
15+
<Version>20.0.3</Version>
1616
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1717
<Description>NosCore's Packets (Nostale packets) defined over classes</Description>
1818
<PackageLicenseExpression>MIT</PackageLicenseExpression>

src/NosCore.Packets/PacketBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public bool IsValid
5252
var nullabilityInfo = nullabilityContext.Create(prop);
5353
if (nullabilityInfo.WriteState is not NullabilityState.Nullable)
5454
{
55-
var attr = new RequiredAttribute();
55+
var attr = new RequiredAttribute { AllowEmptyStrings = true };
5656
var result = attr.GetValidationResult(value, vc);
5757
if (result != null)
5858
{

0 commit comments

Comments
 (0)