fix: registration form — phone mask, required fields, snake_case body

- Address and phone now required (frontend + backend)
- Phone input mask: +7 (XXX) XXX-XX-XX
- Fix Bad Request: register body now sends snake_case keys
  (req() converts camelCase→snake_case, backend schema updated to match)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-30 11:23:24 +03:00
parent 0088457f51
commit 1970afdd13
3 changed files with 62 additions and 24 deletions

View File

@@ -89,11 +89,11 @@ const auth: FastifyPluginAsync = async (fastify) => {
// ── POST /api/auth/register ────────────────────────────────────────────────
fastify.post<{
Body: {
hotelName: string
address?: string
hotel_name: string
address: string
contact: string
email: string
phone?: string
phone: string
password: string
}
}>(
@@ -102,20 +102,20 @@ const auth: FastifyPluginAsync = async (fastify) => {
schema: {
body: {
type: 'object',
required: ['hotelName', 'contact', 'email', 'password'],
required: ['hotel_name', 'address', 'contact', 'email', 'phone', 'password'],
properties: {
hotelName: { type: 'string', minLength: 2 },
address: { type: 'string' },
contact: { type: 'string', minLength: 2 },
email: { type: 'string' },
phone: { type: 'string' },
password: { type: 'string', minLength: 8 },
hotel_name: { type: 'string', minLength: 2 },
address: { type: 'string', minLength: 2 },
contact: { type: 'string', minLength: 2 },
email: { type: 'string' },
phone: { type: 'string', minLength: 5 },
password: { type: 'string', minLength: 8 },
},
},
},
},
async (request, reply) => {
const { hotelName, address, contact, email, phone, password } = request.body
const { hotel_name: hotelName, address, contact, email, phone, password } = request.body
if (!/[a-zA-Zа-яА-ЯёЁ]/.test(password)) {
return reply.code(400).send({ error: 'Пароль должен содержать хотя бы одну букву' })