twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.84k stars 1.75k forks source link

Trim whitespace at the beginning and end of strings. #5799

Open Bonapara opened 3 months ago

Bonapara commented 3 months ago

Current Behavior

I can create an email that has spaces at the end: "example@test.com "

Desired Behavior

We want to automatically remove spaces at the beginning and end of every field input.

greptile-apps[bot] commented 3 months ago

Disclaimer: This comment was automatically generated with AI. It can give some useful hints as to where to look for, but sometimes it can also give very inaccurate answers so takes this with a pinch of salt :).

To trim whitespace at the beginning and end of strings for user input fields, follow these steps:

  1. Locate DTO Files: The relevant DTO files for user input fields are located in the src/dto directory.

  2. Modify Setters or Validation Decorators: Implement trimming of whitespace in the setters or validation decorators for these fields. For example, in src/dto/UserInput.dto.ts, modify the email field as follows:

import { IsEmail } from 'class-validator';

export class UserInputDTO {
  private _email: string;

  @IsEmail()
  set email(value: string) {
    this._email = value.trim();
  }

  get email(): string {
    return this._email;
  }
}
  1. Repeat for Other Fields: Apply similar changes to other fields in the DTO files where trimming is required.

References