-
|
Hey! I've been using Nylo's form validation and love it, but I've run into a couple of limitations that would be awesome to improve. Current ProblemRight now when you chain validations, they all share the same message: Field.password("Password",
validate: FormValidator(message: "custom message")
.notEmpty() // ← Can't set custom message here
.minLength(8) // ← Or here
.password(strength: 2) // ← Or here
)So if any validation fails, the user just sees "custom message" instead of knowing exactly what went wrong. What I'd Love to See1. Custom messages for each validation methodField.password("Password",
validate: FormValidator()
.notEmpty(message: "Password is required")
.minLength(8, message: "Password must be at least 8 characters")
.password(strength: 2, message: "Password is too weak")
)This way users get specific feedback about what's actually wrong. 2. FormValidator.combine() methodSometimes you want to reuse validation logic or combine multiple validators: FormValidator basicPassword = FormValidator()
.notEmpty(message: "Password is required")
.minLength(8, message: "Too short");
FormValidator strongPassword = FormValidator()
.password(strength: 2, message: "Not strong enough");
Field.password("Password",
validate: FormValidator.combine([basicPassword, strongPassword])
)Real ExampleInstead of this confusing experience: You'd get this clear feedback: Implementation IdeasThe current API could stay exactly the same for backward compatibility, just add optional message parameters: // Old way still works
FormValidator("general message").notEmpty().email()
// New way with specific messages
FormValidator().notEmpty(message: "Required").email(message: "Invalid email")For ImplementationIf this seems like a good fit for Nylo, I could work on implementing it when I have some free time available. Happy to create a pull request if there's interest from the maintainers. Let me know your thoughts on this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @ElAdrixHD, Yeah makes sense. I really like the new syntax too! It would definitely make validation more flexible and customizable for everyone. I'll spend some time this week on the solution and message back here when it's ready. It'll most likely be in If you have any more ideas feel free to drop them here, thanks. |
Beta Was this translation helpful? Give feedback.
Hi @ElAdrixHD,
Yeah makes sense. I really like the new syntax too! It would definitely make validation more flexible and customizable for everyone.
I'll spend some time this week on the solution and message back here when it's ready.
It'll most likely be in
6.8.11.If you have any more ideas feel free to drop them here, thanks.