Skip to content

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

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#36
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

Mirrors NativeAppTemplate-Android PR #49 (Android port of NativeAppTemplate-iOS#60). Mirror the ItemTag pattern (PR #35) for Shop. Server has no caps on Shop name/description; this is a client-only UX guard.

Changes

  • NatConstants: MAXIMUM_SHOP_NAME_LENGTH = 100, MAXIMUM_SHOP_DESCRIPTION_LENGTH = 1_000.
  • strings.xml: new shop_name_is_invalid, shop_description_is_invalid, shop_name_help, shop_description_help (parametric).
  • ShopCreateViewModel + ShopBasicSettingsViewModel:
    • UiState gains maximumNameLength / maximumDescriptionLength (defaulted to the constants).
    • hasInvalidData() splits into hasInvalidDataName() + hasInvalidDataDescription(); the parent now ORs both.
    • updateName() / updateDescription() reject input over the cap (mirrors the existing ItemTagCreateViewModel / ItemTagEditViewModel Android pattern).
  • ShopCreateView + ShopBasicSettingsView: switch supportingText to the two-line layout (always-visible help + conditional red "is invalid" line), matching ItemTagCreateView / ItemTagEditView. Description switches to heightIn(min = 120.dp) + minLines = 4.
  • Tests: maximumNameLength_matchesConstant / maximumDescriptionLength_matchesConstant, boundary tests at 100 / 101 / 1000 / 1001 chars on both ShopCreateViewModelTest and ShopBasicSettingsViewModelTest.

Test plan

  • ./gradlew test → BUILD SUCCESSFUL
  • ./gradlew assembleDebug → BUILD SUCCESSFUL
  • ./gradlew spotlessCheck → BUILD SUCCESSFUL
  • ./gradlew lint → BUILD SUCCESSFUL
  • Manual emulator smoke test:
    • Add Shop: type 105 chars in Name → field truncates to 100 (rejected past 100). Save stays enabled.
    • Add Shop: 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

Mirror the ItemTag pattern (PR #35) for Shop. Server has no caps on Shop
name/description; this is a client-only UX guard.

### Changes
- NatConstants: MAXIMUM_SHOP_NAME_LENGTH = 100,
  MAXIMUM_SHOP_DESCRIPTION_LENGTH = 1_000.
- strings.xml: new shop_name_is_invalid, shop_description_is_invalid,
  shop_name_help, shop_description_help (parametric).
- ShopCreateViewModel + ShopBasicSettingsViewModel:
  - UiState gains maximumNameLength / maximumDescriptionLength
    (defaulted to the constants).
  - hasInvalidData() splits into hasInvalidDataName() +
    hasInvalidDataDescription(); the parent now ORs both.
  - updateName() / updateDescription() reject input over the cap
    (mirrors the existing ItemTagCreateViewModel /
    ItemTagEditViewModel Android pattern).
- ShopCreateView + ShopBasicSettingsView: switch supportingText to the
  two-line layout (always-visible help + conditional red "is invalid"
  line), matching ItemTagCreateView / ItemTagEditView. Description
  switches to heightIn(min=120) + minLines=4.
- Tests: maximumNameLength_matchesConstant /
  maximumDescriptionLength_matchesConstant, boundary tests at
  100 / 101 / 1000 / 1001 chars on both ShopCreateViewModelTest and
  ShopBasicSettingsViewModelTest.

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