Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide Base64Attribute in .NET8 onwards in favour of Base64StringAttribute #188

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Tingle.Extensions.DataAnnotations/Base64Attribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace System.ComponentModel.DataAnnotations;
#if !NET8_0_OR_GREATER
namespace System.ComponentModel.DataAnnotations;

/// <summary>
/// Specifies that a data field value is a well-formed base 64 string.
Expand All @@ -15,6 +16,7 @@ public Base64Attribute() : base("The field {0} must be a valid base64 string.")
public override bool IsValid(object? value)
{
if (value is not string s || string.IsNullOrEmpty(s)) return true;

// attempt to convert from base64
try
{
Expand All @@ -27,3 +29,4 @@ public override bool IsValid(object? value)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
#if !NET8_0_OR_GREATER
using System.ComponentModel.DataAnnotations;

namespace Tingle.Extensions.DataAnnotations.Tests;

Expand Down Expand Up @@ -34,3 +35,4 @@ public void Base64_Validation_Works(string testKey, bool expected)

record TestModel([property: Base64] string? SomeKey);
}
#endif