Skip to content

Commit

Permalink
feature: IMaskedValueObject interface
Browse files Browse the repository at this point in the history
  • Loading branch information
maiconheck committed Dec 8, 2023
1 parent 23e8dee commit ced13a2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Krafted/Directory.build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<Authors>Maicon Heck</Authors>
<Version>5.0.0-rc.3</Version>
<PackageVersion>5.0.0-rc.3</PackageVersion>
<Version>5.0.0</Version>
<PackageVersion>5.0.0</PackageVersion>
<Product>Krafted</Product>
<ProductName>Krafted</ProductName>
<PackageId>$(MSBuildProjectName)</PackageId>
Expand Down
6 changes: 3 additions & 3 deletions src/Krafted/Krafted.ValueObjects/Br/Cnpj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Krafted.ValueObjects.Br
/// <see href="https://pt.wikipedia.org/wiki/Cadastro_Nacional_da_Pessoa_Jur%C3%ADdica">See more</see>.
/// </para>
/// </summary>
public class Cnpj : ValueObject<string>
public class Cnpj : ValueObject<string>, IValueObjectMasked
{
/// <summary>
/// Initializes a new instance of the <see cref="Cnpj"/> class.
Expand All @@ -35,14 +35,14 @@ private Cnpj()
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator Cnpj(string value) => new Cnpj(value);
public static explicit operator Cnpj(string value) => new(value);

/// <summary>
/// Initializes a new instance of the <see cref="Cnpj"/> class.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>A new instance of the <see cref="Cnpj"/> class.</returns>
public static Cnpj NewCnpj(string value) => new Cnpj(value);
public static Cnpj NewCnpj(string value) => new(value);

/// <summary>
/// Returns the string representation of the CNPJ <c>Value</c>.
Expand Down
6 changes: 3 additions & 3 deletions src/Krafted/Krafted.ValueObjects/Br/Cpf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Krafted.ValueObjects.Br
/// <see href="https://pt.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas">See more</see>.
/// </para>
/// </summary>
public class Cpf : ValueObject<string>
public class Cpf : ValueObject<string>, IValueObjectMasked
{
/// <summary>
/// Initializes a new instance of the <see cref="Cpf"/> class.
Expand All @@ -34,14 +34,14 @@ private Cpf()
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator Cpf(string value) => new Cpf(value);
public static explicit operator Cpf(string value) => new(value);

/// <summary>
/// Initializes a new instance of the <see cref="Cpf"/> class.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>A new instance of the <see cref="Cpf"/> class.</returns>
public static Cpf NewCpf(string value) => new Cpf(value);
public static Cpf NewCpf(string value) => new(value);

/// <summary>
/// Returns the string representation of the CPF <c>Value</c>.
Expand Down
17 changes: 17 additions & 0 deletions src/Krafted/Krafted.ValueObjects/IValueObjectMasked.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Krafted.ValueObjects;

/// <summary>
/// Defines a <c>ToString(bool masked = false)</c> method to return the string representation of the Value Object, either masked or unmasked.
/// </summary>
public interface IValueObjectMasked
{
/// <summary>
/// Returns the string representation of the Value Object, either masked or unmasked.
/// <para>
/// If the <c>masked</c> argument is <c>true</c>, the <c>Value</c> is masked; otherwise, the <c>Value</c> is unmasked.
/// </para>
/// </summary>
/// <param name="masked">Whether to mask or not the <c>Value</c> (default false).</param>
/// <returns>The string representation of the Value Object, either masked or unmasked.</returns>
public string ToString(bool masked = false);
}

0 comments on commit ced13a2

Please sign in to comment.