Conversation
|
Caution Review failedThe pull request is closed. """ WalkthroughA new regex-based validation module is introduced for email and UUIDv4 formats, centralizing and updating the validation logic. The main string schema now delegates email and UUIDv4 checks to these new helpers. Comprehensive unit tests are added to verify correct validation behavior for both formats. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant StringSchema
participant isPkg as internals/is
User->>StringSchema: Validate email string
StringSchema->>isPkg: Email(input)
isPkg-->>StringSchema: bool (is valid?)
StringSchema-->>User: Validation result
User->>StringSchema: Validate UUIDv4 string
StringSchema->>isPkg: UUIDv4(input)
isPkg-->>StringSchema: bool (is valid?)
StringSchema-->>User: Validation result
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
internals/is/regex.go (1)
9-10: Case-sensitivity of email & UUID patternsBoth patterns accept only lowercase hex / ASCII letters.
For UUIDs a simple(?i)prefix ((?i)^[0-9a-f]{8}…) avoids rejecting valid uppercase strings without an extrastrings.ToLowerallocation.string.go (1)
8-11: Import alias now unusedAfter delegating email/UUID checks to
internals/is, the local aliasp "github.com/Oudwins/zog/internals"remains the only aliased import; verify it is still necessary in this file. If not, drop the alias to keep import section clean.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
internals/is/regex.go(1 hunks)internals/is/regex_test.go(1 hunks)string.go(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
string.go (1)
internals/is/regex.go (2)
UUIDv4(18-20)
internals/is/regex_test.go (1)
internals/is/regex.go (2)
UUIDv4(18-20)
🪛 GitHub Actions: ci
internals/is/regex_test.go
[error] 152-152: TestUUIDv4 failed: Expected true but was false for multiple UUID values, indicating invalid UUID validation.
🔇 Additional comments (2)
string.go (2)
213-216: Delegation looks goodSwitching to
is.Emailcentralises validation and removes duplicated regexes – ✔️
318-319: See comment on UUID regexThis call inherits the stricter v4-only behaviour. Ensure it matches the intended contract before release to avoid silent breaking change.
| validUUIDs := []string{ | ||
| "9491d710-3185-4e06-bea0-6a2f275345e0", | ||
| "d89e7b01-7598-ed11-9d7a-0022489382fd", | ||
| "00000000-0000-0000-0000-000000000000", | ||
| "b3ce60f8-e8b9-40f5-1150-172ede56ff74", | ||
| "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", | ||
| } | ||
|
|
There was a problem hiding this comment.
“validUUIDs” contains non-v4 & invalid entries – tests are red
00000000-0000-0000-0000-000000000000 (version 0) and
d89e7b01-7598-ed11-… / b3ce60f8-e8b9-40f5-1150-… (variant/version mismatch) do not satisfy the v4 regex, causing CI failure.
Action items:
-validUUIDs := []string{
- "9491d710-3185-4e06-bea0-6a2f275345e0",
- "d89e7b01-7598-ed11-9d7a-0022489382fd",
- "00000000-0000-0000-0000-000000000000",
- "b3ce60f8-e8b9-40f5-1150-172ede56ff74",
- "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09",
-}
+validUUIDs := []string{
+ "9491d710-3185-4e06-bea0-6a2f275345e0",
+ "92e76bf9-28b3-4730-8d7f-cb6bc51f8c09", // adjust to v4
+}
+
+invalidUUIDs = append(invalidUUIDs,
+ "d89e7b01-7598-ed11-9d7a-0022489382fd",
+ "00000000-0000-0000-0000-000000000000",
+ "b3ce60f8-e8b9-40f5-1150-172ede56ff74")Or, if all versions should be accepted, update the production regex accordingly (see comment in regex.go).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| validUUIDs := []string{ | |
| "9491d710-3185-4e06-bea0-6a2f275345e0", | |
| "d89e7b01-7598-ed11-9d7a-0022489382fd", | |
| "00000000-0000-0000-0000-000000000000", | |
| "b3ce60f8-e8b9-40f5-1150-172ede56ff74", | |
| "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", | |
| } | |
| validUUIDs := []string{ | |
| "9491d710-3185-4e06-bea0-6a2f275345e0", | |
| "92e76bf9-28b3-4730-8d7f-cb6bc51f8c09", // adjust to v4 | |
| } | |
| invalidUUIDs = append(invalidUUIDs, | |
| "d89e7b01-7598-ed11-9d7a-0022489382fd", | |
| "00000000-0000-0000-0000-000000000000", | |
| "b3ce60f8-e8b9-40f5-1150-172ede56ff74") |
🤖 Prompt for AI Agents
In internals/is/regex_test.go around lines 137 to 144, the validUUIDs slice
includes UUIDs that are not version 4 or are invalid, causing test failures. To
fix this, replace the entries with only valid version 4 UUIDs that match the v4
regex pattern. Alternatively, if the intention is to accept all UUID versions,
update the production regex in regex.go to match all valid UUID versions
accordingly.
* fix: regex for email * fix: uuid regex * fix: naming
* fix: regex for email * fix: uuid regex * fix: naming
Closes #160
Summary by CodeRabbit