Skip to content

Add Base64String (primitives) #77

@vhrcgcom

Description

@vhrcgcom

Description

Implement Base64String as a ValueObject in the primitives module.

Spec: valid base64-encoded string

Implementation checklist

  • Create src/primitives/base64string.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/primitives/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

Implementation detail

Input / Output

Type Alias
Input String Base64StringInput
Output String — the validated base64 string as-is Base64StringOutput

Normalization

Trim surrounding whitespace.

Validation

  • Must be valid standard Base64 (alphabet A–Z, a–z, 0–9, +, /, with = padding).
  • Validate using the base64 crate (add as optional dependency to the primitives feature) — attempt to decode; if it succeeds the input is valid.
  • Padding must be correct: length must be a multiple of 4 (after trimming).

Extra methods

  • decode() -> Vec<u8> — returns the decoded raw bytes. This operation always succeeds since construction already validates the encoding.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions