I am working on backend .NET API, and I receive a userName
as text field. I would like to store this data into the database. Now, what are the validations needed to be done on this field?
E.g. length check (256 char maybe), forbidden chars (";", "/"", etc) and what else before I store this data in the database?
I want to make sure it's secure so to avoid any type of SQL injection or any malicious thing, I would like to know what are the best practices or what needs to be done to this string.
Also, I would like to support all Unicode char.
Thank you.
I tried,
- Length check 256 chars
- Forbidden char check { ';', ''', '"', '\b', '\r', '\n', '\t', '\0', '\x1a' };
Expecting what else to check before I take user name string to database.