Validate Mbin community names when creating a community - #420
Open
neo22neo wants to merge 1 commit into
Open
Conversation
Mbin rejects magazine names that fall outside /^[a-zA-Z0-9_]{2,25}$/, but
the create-community form only disabled submit on an empty name, so an
invalid name failed server-side with no guidance.
- Add mbin_community_name.dart with pure, tested helpers to validate a
name, describe why it is invalid, and derive a sanitized suggestion.
- Give the shared TextEditor helperText/errorText support.
- In CommunityOwnerPanelGeneral (creation only), on Mbin: show the rule as
helper text, an inline error while the name is invalid, a one-tap
"Use suggestion" action, and keep submit disabled until the name is
valid. Lemmy/PieFed behaviour is unchanged.
- Add flutter_test dev dependency and focused unit tests for the helpers.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N7b7QotawaBJQ4isQKd14x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When creating a community on an Mbin server, the form only disabled the submit button on an empty name. Mbin rejects any magazine name outside
/^[a-zA-Z0-9_]{2,25}$/(RegPatterns::MAGAZINE_NAME), so names with spaces, hyphens, accents, etc. failed server-side with no guidance for the user.Changes
lib/src/utils/mbin_community_name.dart(new) — pure, testable helpers:isValidMbinCommunityName— the^[a-zA-Z0-9_]{2,25}$check.mbinCommunityNameIssue— why a name is invalid (invalidCharacters/tooShort/tooLong); empty is treated as "not entered yet".suggestMbinCommunityName— best-effort sanitized name (unsupported runs →_, collapsed, trimmed, truncated to 25), ornullwhen nothing usable can be salvaged.lib/src/widgets/text_editor.dart— sharedTextEditorgainshelperText/errorTextpassthrough.lib/src/screens/explore/community_owner_panel.dart— inCommunityOwnerPanelGeneral(creation path only), when the active server is Mbin:maxLength: 25, no extra validation).lib/l10n/app_en.arb— new keys:community_nameMbinHelp,community_nameInvalidCharacters,community_nameTooShort,community_nameTooLong,community_nameUseSuggestion.pubspec.yaml/test/— addflutter_testdev dependency and focused unit tests for the new helpers.Notes
MbinOrg/mbinsrc/Utils/RegPatterns.php).dart format/flutter test/flutter gen-l10nwere not run locally — please double-check CI.🤖 Generated with Claude Code