ardanlabs / service

Starter-kit for writing services in Go using Kubernetes.
https://www.ardanlabs.com
Apache License 2.0
3.4k stars 612 forks source link

Write regex! #360

Closed mrbardia72 closed 2 months ago

mrbardia72 commented 2 months ago

If we want to use regex Should it be written in the path below? service/foundation/validate

ardan-bkennedy commented 2 months ago

When you have these questions start with the "purpose" of the code. Without understanding the purpose, it's hard to answer.

ardan-bkennedy commented 2 months ago

Was this a mistake? I don't understand.

mrbardia72 commented 2 months ago

Oh, sorry, there was a mistake

Actually, I know how this code should be written I just wanted to ask if the place where I should check regex is this part or not

ardan-bkennedy commented 2 months ago

I can't give you guidance on where to put it if I don't know the purpose of the code as it relates to the project. Saying you have a regex without telling me what and why you have this leaves blind

mrbardia72 commented 2 months ago

For example, I want to check the user name (check means the regex) which has a special regex I want to check the correctness of the username entered by the user

ardan-bkennedy commented 2 months ago

Then you would want a Name type in the user package that would be the type for the name field in the user model. That regex would be used in the Parse function for this Name type.

Look at role.go in the core user package.