Skip to content

Conversation

@SayakaOno
Copy link
Collaborator

Description

  • Migration for market_directory_info permissions.
  • Implement POST /market_directory_info endpoint with tests.
  • Update LiteFarmRequest so that ResBody and ReqBody can be specified.
  • Fix typo in mock.factories.

Note:
Validation logic should be updated when frontend validations for socials and URLs are implemented.

Jira link: https://lite-farm.atlassian.net/browse/LF-4995

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have ordered translation keys alphabetically (optional: run pnpm i18n to help with this)
  • I have added the GNU General Public License to all new files

@SayakaOno SayakaOno self-assigned this Oct 29, 2025
@SayakaOno SayakaOno requested review from a team as code owners October 29, 2025 18:32
@SayakaOno SayakaOno requested review from kathyavini and removed request for a team October 29, 2025 18:32
@SayakaOno SayakaOno added the enhancement New feature or request label Oct 29, 2025
phone_number: { type: ['string', 'null'], maxLength: 255 },
address: { type: 'string', minLength: 1, maxLength: 255 },
website: { type: ['string', 'null'] },
website: { type: ['string', 'null'], maxLength: 2000 },
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@SayakaOno SayakaOno marked this pull request as draft November 3, 2025 16:57
* Extract username
* Adjust checkAndTransformMarketDirectoryInfo and tests
@SayakaOno
Copy link
Collaborator Author

Updated social validation to be stricter, and the function now only returns a username.
Since we didn’t have tests for API utils before, I added a new "utils-tests" folder under tests (similar to how the frontend has a dedicated test folder).

@SayakaOno SayakaOno marked this pull request as ready for review November 4, 2025 16:45
Copy link
Collaborator

@kathyavini kathyavini left a comment

Choose a reason for hiding this comment

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

It looks fantastic! I love the social validations and their test suite ❤️

Now that I've seen it, I think I might go completely against what I said yesterday (😓) and run social validation and trim on the frontend as well, onBlur() -- that actually might be easier than parsing each error message for the offending social when the error is returned from the API. Do you anticipate any problems with moving validateSocialAndExtractUsername() into packages/shared?

// 3: username ([A-Za-z0-9._-]+)
// 4: trailing path/query (optional) ([/?#].*)? e.g., "/?hl=en", "/#"
const urlMatch = trimmedInput.match(
new RegExp(`^(https?://)?(www.)?${domain}/([A-Za-z0-9._-]+)([/?#].*)?$`),
Copy link
Collaborator

@kathyavini kathyavini Nov 4, 2025

Choose a reason for hiding this comment

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

I think the validations you picked are the perfect balance of permissive and strict 👌

The only thing I wonder if we should be a tiny bit more permissive on would be a capitalized domain? Like Facebook.com/username or Instagram.com/username? My Android phone does this initial capitalization automatically in form fields so I bet other systems do too.

Maybe just this regex could be case insensitive ('i')?

@kathyavini kathyavini added this pull request to the merge queue Nov 4, 2025
Merged via the queue into integration with commit 5a6c9b2 Nov 4, 2025
4 of 5 checks passed
@SayakaOno SayakaOno deleted the LF-4995/Create_POST_endpoint_to_add_Market_directory_info branch November 5, 2025 16:14
@SayakaOno
Copy link
Collaborator Author

Thank you @kathyavini!
I'll make the regex case insensitive. My Android phone behaves the same way as yours!
As for moving validateSocialAndExtractUsername() into packages/shared, I'm just not sure about adding TS files and tests there. I'm guessing we'd need some adjustments (like updating the Dockerfiles, adding a GitHub workflow, and setting up Jest) 🤔

@kathyavini
Copy link
Collaborator

@SayakaOno oh yeah TypeScript, duh 🤦‍♀️ I did try the straight import yesterday, saw it didn't work, and copied the file to frontend 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants