Table of Contents

Class ValueMasker

Namespace
GroupeIsa.Neos.Shared.Masking
Assembly
GroupeIsa.Neos.Shared.dll

Masks string values. A masker is built once from a MaskingSpecification, is stateless and can be shared by concurrent requests.

public abstract class ValueMasker
Inheritance
ValueMasker
Inherited Members

Remarks

A masker never returns a value in clear by accident: a value that does not have the expected format, an error while masking, or a mask that would hide nothing all end in a full mask.

Constructors

ValueMasker(char)

Initializes a new instance of the ValueMasker class.

protected ValueMasker(char maskCharacter)

Parameters

maskCharacter char

The character that replaces each masked character.

Properties

MaskCharacter

Gets the character that replaces each masked character.

protected char MaskCharacter { get; }

Property Value

char

Methods

Create(MaskingSpecification)

Creates the masker described by a specification.

public static ValueMasker Create(MaskingSpecification specification)

Parameters

specification MaskingSpecification

The masking specification.

Returns

ValueMasker

The masker.

Exceptions

ArgumentException

The specification is not valid.

HasMaskedForm(string)

Determines whether a value has the form of a masked value: it holds the masking character, and masking it again leaves it unchanged or masks it fully.

public virtual bool HasMaskedForm(string value)

Parameters

value string

The value.

Returns

bool

true when the value can be a masked one.

Remarks

A mask, even one edited in its visible parts, is unchanged when masked again. A real value that holds the masking character is changed, unless the format does not accept it.

Mask(string?)

Masks a value.

public string? Mask(string? value)

Parameters

value string

The value to mask.

Returns

string

The masked value. null and empty values are returned as is.

MaskCore(string)

Masks a non-empty value.

protected abstract string MaskCore(string value)

Parameters

value string

The value to mask, never null nor empty.

Returns

string

The masked value.

MaskFully(string)

Masks every character of a value, separators included. Used as well whenever masking fails or hides nothing.

protected virtual string MaskFully(string value)

Parameters

value string

The value to mask.

Returns

string

One masking character per character of the value.