Skip to content

Add CodingTransformer map helpers#29

Merged
WendellXY merged 1 commit into
mainfrom
feat/coding-transformer-map-helpers
Jun 17, 2026
Merged

Add CodingTransformer map helpers#29
WendellXY merged 1 commit into
mainfrom
feat/coding-transformer-map-helpers

Conversation

@WendellXY

Copy link
Copy Markdown
Owner

Summary

  • Add CodingTransformer.map(_:) for lightweight output projections.
  • Add optional-output shortcuts for default-before-map and failable-map-with-fallback pipelines.
  • Cover success, upstream failure, thrown mapping failure, optional defaults, and enum raw-value fallback behavior.
  • Document the concise account-type mapping pattern in the README.

Tests

  • swift format lint --strict Sources/CodableKit/Transformers/CodingTransformer.swift Sources/CodableKit/Transformers/CodingTransformerComposition.swift Tests/TransformerTests/DerivedValueTransformerTests.swift
  • git diff --check
  • swift test --filter DerivedValueTransformerTests
  • swift test

Copilot AI review requested due to automatic review settings June 16, 2026 12:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends CodingTransformer with convenient map helpers to enable lightweight output projections and common optional/default mapping pipelines, and documents the pattern for derived properties.

Changes:

  • Add CodingTransformer.map(_:) to map successful outputs while propagating upstream failures and mapping-thrown errors.
  • Add map(defaultValue:_:) and map(defaultValue:fallbackValue:_:) to streamline optional-output pipelines (default-before-map and failable-map-with-fallback).
  • Add targeted tests for success/failure propagation and optional/fallback behaviors, plus README documentation for the derived-key usage pattern.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
Sources/CodableKit/Transformers/CodingTransformer.swift Adds the public map helper overloads on CodingTransformer.
Sources/CodableKit/Transformers/CodingTransformerComposition.swift Introduces MapTransformer implementation used by map(_:) and removes redundant explicit initializers (memberwise inits suffice).
Tests/TransformerTests/DerivedValueTransformerTests.swift Adds test coverage for mapping success, upstream failure propagation, thrown mapping failures, and optional/fallback variants.
README.md Documents the new .map helpers with a concise derived-property example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@WendellXY WendellXY self-assigned this Jun 17, 2026
@WendellXY WendellXY merged commit f69ad82 into main Jun 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants