Skip to content

Add client-side length caps + truncation for Shop name/description#50

Merged
dadachi merged 1 commit intosubstrate-v2from
substrate-v2--shop-name-description-caps
Apr 27, 2026
Merged

Add client-side length caps + truncation for Shop name/description#50
dadachi merged 1 commit intosubstrate-v2from
substrate-v2--shop-name-description-caps

Conversation

@dadachi
Copy link
Copy Markdown
Contributor

@dadachi dadachi commented Apr 27, 2026

Summary

Ports nativeapptemplate/NativeAppTemplate-iOS#60. Mirror the ItemTag pattern from #49 for Shop. Server has no caps on Shop name/description; this is a client-only UX guard.

  • Constants: `maximumShopNameLength = 100`, `maximumShopDescriptionLength = 1_000`. New strings: `shopNameIsInvalid`, `shopDescriptionIsInvalid`, plus `shopNameHelp(maximumLength:)` / `shopDescriptionHelp(maximumLength:)` parametric helpers.
  • `ShopCreateViewModel` + `ShopBasicSettingsViewModel`: split `hasInvalidData` into `hasInvalidDataName` + `hasInvalidDataDescription`, expose `maximumNameLength` / `maximumDescriptionLength`, add `validateNameLength()` / `validateDescriptionLength()`.
  • `ShopCreateView` + `ShopBasicSettingsView`: wire `.onChange` truncation on Name and Description; switch to two-line footer (always-visible help + conditional red "is invalid" text), matching `ItemTagCreateView`.
  • Tests: added `maximumNameLength`, `maximumDescriptionLength`, parametric `nameValidation` / `descriptionValidation`, and the two truncation tests on both view-model test suites; replaced the old simple `hasInvalidData(name:)` parametric test in `ShopCreateViewModelTest`.

Test plan

  • `xcodebuild build-for-testing` — `** TEST BUILD SUCCEEDED **`
  • `make lint` — `0 violations` (SwiftLint + SwiftFormat)
  • `xcodebuild test` passes (please verify in Xcode with Cmd+U). New parametric tests should cover boundary cases at 100 / 101 / 1000 / 1001 chars.
  • Manual:
    • Open Add Shop, type 105 chars in Name → field truncates to 100, no red error. Save stays enabled.
    • Type 1500 chars in Description → truncates to 1000.
    • Clear Name → red "Shop name is invalid." appears, Save disabled.
    • Same on Shop Settings → Basic Settings.

🤖 Generated with Claude Code

Ports nativeapptemplate/NativeAppTemplate-iOS#60.
Mirror the ItemTag pattern from PR #49 for Shop. Server has no caps on
Shop name/description; this is a client-only UX guard.

- Constants: maximumShopNameLength = 100, maximumShopDescriptionLength
  = 1_000. New strings: shopNameIsInvalid, shopDescriptionIsInvalid,
  plus shopNameHelp(maximumLength:) / shopDescriptionHelp(maximumLength:)
  parametric helpers.
- ShopCreateViewModel + ShopBasicSettingsViewModel: split hasInvalidData
  into hasInvalidDataName + hasInvalidDataDescription, expose
  maximumNameLength / maximumDescriptionLength, add validateNameLength()
  / validateDescriptionLength().
- ShopCreateView + ShopBasicSettingsView: wire .onChange truncation on
  Name and Description; switch to two-line footer (always-visible help
  + conditional red "is invalid" text), matching ItemTagCreateView.
- Tests: added maximumNameLength, maximumDescriptionLength, parametric
  nameValidation / descriptionValidation, and the two truncation tests
  on both viewmodel test suites; replaced the old simple
  hasInvalidData(name:) parametric test in ShopCreateViewModelTest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dadachi dadachi merged commit d6039a0 into substrate-v2 Apr 27, 2026
2 checks passed
@dadachi dadachi deleted the substrate-v2--shop-name-description-caps branch April 27, 2026 09:22
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.

1 participant