Files
banu-front/src/features/admin/users/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

33 lines
1.2 KiB
JavaScript

import { number, 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 rejectionReasonSchema = object().shape({
reason: string().required(),
})
const baseUserShape = {
role: string().required(),
name: string().required().min(3),
phone: phoneNumberRule,
nationalCode: nationalCodeRule,
birthday: string().nullable().notRequired(),
maritalStatus: string().nullable().notRequired(),
gender: string().nullable().notRequired(),
bio: string().nullable().notRequired(),
provinceId: string().nullable().notRequired(),
cityId: string().nullable().notRequired(),
address: string().nullable().notRequired(),
avatarMediaId: number().typeError('شناسه تصویر پروفایل باید عدد باشد').nullable().notRequired(),
}
export const userAddSchema = object().shape({
...baseUserShape,
password: passwordRule,
passwordConfirmation: passwordConfirmationRule,
})
export const userEditSchema = object().shape(baseUserShape)