Files
banu-front/src/features/student/profile/schema/index.js
T
sajjadtalkhabi fec1da6ec8
Deploy banu-front / deploy (push) Successful in 1m50s
fix: localize Yup validation messages
2026-08-14 21:08:52 +03:30

42 lines
1.6 KiB
JavaScript

import { object, string } from 'yup'
import { passwordRule } from '@/constants/rules/passwordRule'
import { phoneNumberRule } from '@/constants/rules/phoneNumberRule'
import { nationalCodeRule } from '@/constants/rules/nationalCodeRule'
import { passwordConfirmationRule } from '@/constants/rules/passwordConfirmationRule'
export const studentProfileSchema = object().shape({
name: string().required().min(2),
phone: phoneNumberRule,
nationalCode: nationalCodeRule,
birthday: string().nullable().notRequired(),
marriageStatus: string().nullable().notRequired(),
gender: string().nullable().notRequired(),
provinceId: string().nullable().notRequired(),
cityId: string().nullable().notRequired(),
address: string().nullable().notRequired(),
postalCode: string()
.nullable()
.notRequired()
.matches(/^\d{10}$/, { message: 'کد پستی باید ۱۰ رقم باشد', excludeEmptyString: true }),
virtualPhoneNumber: string()
.nullable()
.notRequired()
.matches(/^\d{10,15}$/, {
message: 'شماره تلفن مجازی باید فقط شامل ۱۰ تا ۱۵ رقم باشد',
excludeEmptyString: true,
}),
seminaryCode: string().nullable().notRequired(),
seminaryServiceCenterCode: string().nullable().notRequired(),
childrenCount: string()
.nullable()
.notRequired()
.matches(/^\d+$/, { message: 'تعداد فرزند باید عدد باشد', excludeEmptyString: true }),
})
export const studentResetPasswordSchema = object().shape({
phone: phoneNumberRule,
password: passwordRule,
passwordConfirmation: passwordConfirmationRule,
})