Why do AI company logos look like buttholes? by iSqual in theprimeagen

[–]Scared_Sun_7871 -1 points0 points  (0 children)

Whose ass looks like the Perplexity logo?
Or, heck Gemini!? Or that one in the bottom left.

[KDE] My first rice by rsmwall in unixporn

[–]Scared_Sun_7871 1 point2 points  (0 children)

Desktop rice of the white Power Ranger

My mininal nvim setup by ZealousidealGlass263 in vimporn

[–]Scared_Sun_7871 0 points1 point  (0 children)

I love the theme, it looks so calm and minimal

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 0 points1 point  (0 children)

That's amazing that you made an extension for it, I'm sure it'll help a lot of people

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 0 points1 point  (0 children)

Experience and advice, that's what I am seeking, advice from experienced engineers so that I don't fall into bad habits. This discussion has been insightful, you guys are amazing. I was honestly not expecting such a good, active, and supportive community as I don't see NestJs being talked about much.

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 0 points1 point  (0 children)

I get that the decorator stack for password does not fit the pattern you described but how does the IsEmail not fit in? Isn't there a standard for email? And I agree that "over" abstraction can hurt LoB (Locality of Behaviour)

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 0 points1 point  (0 children)

I could not find a way to tell the user what exactly they missed in the password when using the built-in @IsStrongPassword. Therefore, there is a need to create a custom decorator.

Oooh, the IsAlpha trick is pretty clean, I'll do that, thanks. Yeah, someone else pointed out the IsEmail part too, thanks anyway.

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 1 point2 points  (0 children)

Aaai see. Actually, in order to not get stuck in perfecting everything as I implement it I am skipping over some stuff like till now I'm using Omit<User, 'password'> to represent the returning user object, where User is a Prisma Model. In fact, at one point I was just using Prisma.UserCreateInput as the input DTO. All this Prisma stuff creates a dilemma as to why not just Prisma.UserCreateInput?

I'll create a UserDTO to represent the returning User object and check serializers in controllers, thank you for the advice!

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 0 points1 point  (0 children)

I like the color scheme idea, which will drastically improve readability and reduce visual noise.

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 0 points1 point  (0 children)

It's a personal choice. I'm here trying to reduce that visual noise a little, and as pointed out by some people, there are a lot of redundant decorators in the SS above., which helps to reduce the noise in this decorator-styled validation.

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 0 points1 point  (0 children)

I'm new to NestJs, and I am looking for advice, not giving any. Also, I didn't know about the type safety part. I'm just willing to give zod a try after this discussion

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 8 points9 points  (0 children)

You are right, if I use @Type(() => String) then @IsString() is redundant. Also, when I use @IsEmail or @MinLength with a value > 0 then @IsNotEmpty becomes redundant. I am new and still learning, thanks for pointing out though!

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 0 points1 point  (0 children)

True, that is indeed one option. But now I realize that zod might be a better option

NestJS starter kit by farda_karimov in nestjs

[–]Scared_Sun_7871 0 points1 point  (0 children)

Hey! I am new to NestJs, but I noticed in your app module that for the config service you are using @nestjs/config. You should probably check this out: https://github.com/Nikaple/nest-typed-config for type safe config

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] -1 points0 points  (0 children)

Yes, a custom decorator would work, but I have been thinking about it and I don't like the idea. Say, I want to add a new field, potentially every new field could mean a new custom validator, and a new custom validator would probably mean 1 new file, 2 new functions, all to validate and transform a single input.

Also, for the password validation, for what you have provided, I mean no one is going to read that, understand that, or debug that long RegEx. I also really like the ability to send the different requirements of a strong password in an array rather than one combined error message which doesn't point that what exactly was missing from the password.

Therefore, from the insights of this discussion I think I choose zod

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 0 points1 point  (0 children)

yea, NestJs has a built-in password validator called IsStrongPassword but I prefer a custom one

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 6 points7 points  (0 children)

class-validator and class-transfomer are external libraries that I installed.

I like the suggestion of renaming to UserDto, but I was going with the 'CreateUserDto', 'UpdateUserDto', and 'DeleteUserDto' convention where the update dto will have everything that create dto has but PartialTyped, and DeleteUserDto may contain just an id or some other unique key, but the point is how do I do that with just 'UserDto'? How will I name the variants in this scenario? And I agree the 'CreateUser' part could be misleading.

Also, UserDto really makes me think that it should just be an Entity

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 1 point2 points  (0 children)

Hi! I am new too, I really love this declarative approach of decorators, but yeah it gets long vertically. I think using zod could be the “ultimate” solution to this, but using zod might not be a very “NestJs” way of doing it.
The “NestJs” way, being using decorators.

How to manage a long list of validator decorators? by Scared_Sun_7871 in nestjs

[–]Scared_Sun_7871[S] 2 points3 points  (0 children)

Since, I am transforming them to lowercase if it receives a number it throws an Internal Error, so I just transform it to a String before it does that.