Spaces:
Running

Bot / frontend /src /features /admin-console /schemas /adminSchema.ts
ddosvn's picture
Initial deploy of Panel ThTuanIT full stack and Lighthouse-optimized frontend
7e79d39 verified
Raw History Blame Contribute Delete
717 Bytes
import { requiredText, ValidationResult } from '@/shared/lib/validation';
export function validatePasswordChange(
currentPassword: string,
newPassword: string,
confirmPassword: string,
): ValidationResult<{ currentPassword: string; newPassword: string }> {
const curErr = requiredText(currentPassword, 'Mật khẩu hiện tại', 1, 200);
if (curErr) return { ok: false, error: curErr };
const newErr = requiredText(newPassword, 'Mật khẩu mới', 6, 200);
if (newErr) return { ok: false, error: newErr };
if (newPassword !== confirmPassword) {
return { ok: false, error: 'Xác nhận mật khẩu mới không khớp.' };
}
return { ok: true, data: { currentPassword, newPassword } };
}