feat: add validation for Revolut profile name format
- Add ownerRevolutProfileName field validation when enableRevolutPayment is true - Validate profile name must start with '@' and contain only letters and numbers - Add required field validation for Revolut profile name - Add English and Croatian error messages for validation failures - Update State type to include ownerRevolutProfileName errors Validation regex: /^@[a-zA-Z0-9]+$/ Valid examples: @john123, @ivan, @user2024 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ export type State = {
|
||||
ownerTown?: string[];
|
||||
ownerIBAN?: string[];
|
||||
currency?: string[];
|
||||
ownerRevolutProfileName?: string[];
|
||||
};
|
||||
message?: string | null;
|
||||
success?: boolean;
|
||||
@@ -96,6 +97,26 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
|
||||
}, {
|
||||
message: t("currency-required"),
|
||||
path: ["currency"],
|
||||
})
|
||||
.refine((data) => {
|
||||
if (data.enableRevolutPayment) {
|
||||
return !!data.ownerRevolutProfileName && data.ownerRevolutProfileName.trim().length > 0;
|
||||
}
|
||||
return true;
|
||||
}, {
|
||||
message: t("owner-revolut-profile-required"),
|
||||
path: ["ownerRevolutProfileName"],
|
||||
})
|
||||
.refine((data) => {
|
||||
if (data.enableRevolutPayment && data.ownerRevolutProfileName) {
|
||||
const profileName = data.ownerRevolutProfileName.trim();
|
||||
// Must start with @ and contain only English letters and numbers
|
||||
return /^@[a-zA-Z0-9]+$/.test(profileName);
|
||||
}
|
||||
return true;
|
||||
}, {
|
||||
message: t("owner-revolut-profile-invalid"),
|
||||
path: ["ownerRevolutProfileName"],
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user