feat: min max chars for long text #15691
Conversation
…chars' into features/long-text-min-max-chars
…long-text-min-max-chars
|
@varshith257 is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
I feel this is better and cleaner with passing e2e tests too @anikdhabal is also following up with his reviews and am following it. To work together then let us split the bounty as of efforts taken WDYT? @hariombalhara . Collaboration is cool in Open Source :) |
I have closed my pr. please handle the edge case. I have handled it in my pr. if needed take reference. packages/features/form-builder/FormBuilder.tsx |
I think it's not needed IMO |
|
@hariombalhara @anikdhabal Can have a look into it and merge it? |
| if (hasExceededMaxLength) { | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| message: m(`Max. ${field.maxLength} characters allowed`), | ||
| }); | ||
| } |
| function FieldWithLengthCheckSupport({ | ||
| fieldForm, | ||
| containerClassName = "", | ||
| className, | ||
| ...rest |
There was a problem hiding this comment.
Refactored the new component changes out from the parent component.
| const maxLength = field.maxLength ?? fieldTypeConfig.supportsLengthCheck?.maxLength; | ||
| const minLength = field.minLength ?? 0; |
There was a problem hiding this comment.
Ensured that maxLength and minLength are initialized correctly and use them only and not field props.
hariombalhara
left a comment
There was a problem hiding this comment.
@varshith257 Made some changes to cleanup the code a bit more and fixed a bug.
Please review the changes made by me. It is good to go from my side.
@ThyMinimalDev Please review the v2 API related changes.
|
@hariombalhara Thanks for fixing the bug and cleanup. I have semester exams ongoing so hadn't looked at it. |
No Problem. Good luck with your exams !! |
There was a problem hiding this comment.
Great PR and well done on adding e2e test!
However, the API part needs:
- To specifiy min and max length on the individual booking field input and output, not the whole event-type object.
- To add this functionality also to the latest event-types release.
Let me know if I can provide more details / explain anything : )
| @ValidateNested({ each: true }) | ||
| @Type(() => Source) | ||
| sources?: Source[]; | ||
|
|
There was a problem hiding this comment.
I see that inputs and outputs of event-types in folder event-types_2024_04_15 are updated, but we also need to update inputs and outputs used by next release in the folder event-types_2024_06_14
The controller apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.ts takes inputs from packages/platform/types/event-types/event-types_2024_06_14/inputs and outputs from apps/api/v2/src/ee/event-types/event-types_2024_06_14/outputs that share underlying event-type output defined in packages/platform/types/event-types/event-types_2024_06_14/outputs/event-type.output.ts.
As you see, the inputs and outputs are in the platform-types package , which means that after changing them you have to re-build them by running rm -rf dist && npx tsc --build --force in the packages/platform/types folder.
|
|
||
| @IsOptional() | ||
| @IsNumber() | ||
| maxLength?: number; |
There was a problem hiding this comment.
I think that maxLength and minLength should not be defined on the input object, but on the level of individual booking field, be it class BookingField_2024_04_15 or TextField_2024_06_14 within packages/platform/types/event-types/event-types_2024_06_14/inputs/booking-fields.input.ts.
Same logic applies as comment above - we need to also handle the 2024_06_14 release of event-types.
|
|
||
| @IsOptional() | ||
| @IsNumber() | ||
| maxLength?: number; |
There was a problem hiding this comment.
Same as with inputs above - I think min and max length should be part of the individual booking field, because right now we are defining min and max length of an event type.
|
@supalarry mind making these changes? Sounds like @varshith257 is busy and might not be able to get them in. |
Now that I think it's better to have web app only update in this PR and then API update in separate one - I will remove API stuff from this PR so we can ship this already and add to-do for this API task. |
supalarry
left a comment
There was a problem hiding this comment.
Great job Vamshi! Tested locally and works!

What does this PR do?
Part of #15577
This PR adds an optional minimum and maximum character limit to long text question in the booking form.
Loom Video: https://www.loom.com/share/735a6768a92847cabefd1fe2187c499d?sid=2d606562-c6e6-4bd3-92c0-b1fcdab14218
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Are there environment variables that should be set?
No
What are the minimal test data to have?
NA
What is expected (happy path) to have (input and output)?
Click on Event Types in the sidebar.
Click on an event.
Inside the event, click on the Advanced tab on the left sidebar.
Add / edit a question.
Set type to Long text
Set the min &/or max characters.
Save the question.
Save the form.
Click on the Preview button in the event header.
Select a date on the calendar.
While filling out the form, click save button with:
a. Min &/or max character limit unsatisfied -> should show red text with error.
b. All the conditions satisfied -> Should save successfully.
Any other important info that could help to test that PR
/claim #15577