Fastapi: validate input registration

Created on 30 Sep 2020  Â·  6Comments  Â·  Source: tiangolo/fastapi

Hi guys!
I want to add validate input when user register. I don't know how can i do it? do you help me?

question

Most helpful comment

Feel free to paste the code into a comment with appropriate code formatting

All 6 comments

Yes i can definitely help about validating the input from user register, if you prove some minimal, reproducible example...

Yes. Thanks for your reply.
I download folder keycloak-11.0.2 into keycloak.org website. I run keycloak server by command
"./standalone.sh -Djboss.socket.binding.port-offset=100". It is running.

I create realm. Into realm, I create client, role, .... But when I register user, the password field works fine even if I enter 1 character, this is not okay and I want to validate the password input field. Similar to other filed.

Can i see your endpoint and your Pydantic Model, it's quite hard to help without seeing your code.

Oh! Thanks for your reply. I am sorry. When I comment on github, i can't
add image. I will send image on here.

On Thu, 1 Oct 2020, 19:50 Yağızcan Değirmenci, notifications@github.com
wrote:

Can i see your endpoint and your Pydantic Model, it quite hard to help
without them.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/tiangolo/fastapi/issues/2112#issuecomment-702111903,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AMYODCG7KDVH3I2W2W4RYE3SIR3IZANCNFSM4R7JYAXA
.

Feel free to paste the code into a comment with appropriate code formatting

Yes. Thanks for your reply.
I download folder keycloak-11.0.2 into keycloak.org website. I run keycloak server by command
"./standalone.sh -Djboss.socket.binding.port-offset=100". It is running.

I create realm. Into realm, I create client, role, .... But when I register user, the password field works fine even if I enter 1 character, this is not okay and I want to validate the password input field. Similar to other filed.

So if I understand correctly, you want to interact with Keycloak API from your FastAPI app, and you want user given input data validated. You would have to create Pydantic models with the validation rules you want (refer to Pydantic documentation), and use these models as request body in your endpoints (refer to FastAPI documentation). You can use pydantic Fields to set the min length for fields like the password.

Was this page helpful?
0 / 5 - 0 ratings