New Feature: Custom validation rules
- Andrea
- Topic Author
- Offline
- Elite Member
Less
More
6 years 8 months ago #112208
by Andrea
Visit my page! www.elementotango.it
Replied by Andrea on topic New Feature: Custom validation rules
Hi Tuan, thank-you for picking this up.
Yes, basically the idea is to have a file (php file) where we can build whatever number of functions we want. Then, in the EB custom fields creation, we specify the name of the function we want to call to validate the field's content. This way, if we don't specify anything, the field will not be checked against any special rule. If we specify a function name, then EB will look into the php file and search for that validation function. It will return true or false depending on the result of the function. So, a "False" will not accept the field's contents, like when you don't put a correct email into an email field or a phone number in the right field in your pre-defined fields.
Hope this makes sense.
Thanks!
Andrea.
Yes, basically the idea is to have a file (php file) where we can build whatever number of functions we want. Then, in the EB custom fields creation, we specify the name of the function we want to call to validate the field's content. This way, if we don't specify anything, the field will not be checked against any special rule. If we specify a function name, then EB will look into the php file and search for that validation function. It will return true or false depending on the result of the function. So, a "False" will not accept the field's contents, like when you don't put a correct email into an email field or a phone number in the right field in your pre-defined fields.
Hope this makes sense.
Thanks!
Andrea.
Visit my page! www.elementotango.it
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
6 years 8 months ago #112209
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic New Feature: Custom validation rules
I will think to see what's the best way to handle this requirement. As of right now, the way we work (with core) is that when a validation is failed, there should be an error message returned to explain the error
Maybe there should be something similar to custom validation, too. The system will pass the value of the field to method call / rule and then that custom rule will check. If it's not valid, then it will return an error message. If it's valid, nothing is returned
Maybe there should be something similar to custom validation, too. The system will pass the value of the field to method call / rule and then that custom rule will check. If it's not valid, then it will return an error message. If it's valid, nothing is returned
Please Log in or Create an account to join the conversation.
- Andrea
- Topic Author
- Offline
- Elite Member
6 years 8 months ago #112210
by Andrea
Visit my page! www.elementotango.it
Replied by Andrea on topic New Feature: Custom validation rules
Yes, I think that would be a good idea. Clearly we could go as further as we potentially like, for example to can customize in the php the error message we want to be displayed for every rule (assigning the error message to a string in the fuction, to be returned to the form) but as a minimum a generic fail message could be OK. I'm thinking at something like "Invalid Entry" or similar.
Visit my page! www.elementotango.it
Please Log in or Create an account to join the conversation.
- Russell Noble
- Offline
- Premium Member
Less
More
- Posts: 103
- Thank you received: 5
6 years 8 months ago #112211
by Russell Noble
Replied by Russell Noble on topic New Feature: Custom validation rules
I'd suggest the function should accept an array containing the field values, and returns true if valid or an error string if not. You want all the filled in fields in the array so the validation can implement dependencies.
The is validation library currently used dues support custom validations and we actually currently use this, but you really want the validation also performed server side.
The is validation library currently used dues support custom validations and we actually currently use this, but you really want the validation also performed server side.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
6 years 8 months ago #112421
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic New Feature: Custom validation rules
Thinking about it for a while, I decided that I will implement this server side validation library
respect.github.io/Validation/
It supports so many custom validation rules respect.github.io/Validation/docs/validators.html , so it would work for most of the case. I will see how we can add custom validation rule too it, too and will make a document for it
Tuan
It supports so many custom validation rules respect.github.io/Validation/docs/validators.html , so it would work for most of the case. I will see how we can add custom validation rule too it, too and will make a document for it
Tuan
The following user(s) said Thank You: Andrea, Eileen
Please Log in or Create an account to join the conversation.
- Eileen
- Offline
- Junior Member
Less
More
- Posts: 30
- Thank you received: 2
6 years 8 months ago #112431
by Eileen
Replied by Eileen on topic New Feature: Custom validation rules
Awesome!
Please Log in or Create an account to join the conversation.
- abarrow
- Offline
- Senior Member
Less
More
- Posts: 70
- Thank you received: 1
6 years 8 months ago #112438
by abarrow
Replied by abarrow on topic New Feature: Custom validation rules
That's great news, Tuan!
Please Log in or Create an account to join the conversation.
- Andrea
- Topic Author
- Offline
- Elite Member
6 years 8 months ago #112446
by Andrea
Visit my page! www.elementotango.it
Replied by Andrea on topic New Feature: Custom validation rules
Hello Tuan, I'm not familiar with the library you mention, nevertheless the fact you are working on this is simply awesome! Can't wait to start using it !
Thanks!
Andrea
Thanks!
Andrea
Visit my page! www.elementotango.it
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
6 years 8 months ago #112814
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic New Feature: Custom validation rules
Just for your information, here is what was implemented
eventbookingdoc.joomservices.com/basic-s...eld-data-server-side
and will be available in next release. You can use both existing validators or build custom validators yourself
Regards,
Tuan
Regards,
Tuan
Please Log in or Create an account to join the conversation.
- Russell Noble
- Offline
- Premium Member
Less
More
- Posts: 103
- Thank you received: 5
6 years 8 months ago #112815
by Russell Noble
Replied by Russell Noble on topic New Feature: Custom validation rules
Tuan,
I just want to check, having read the documentation I'm assuming the validation is for a single field? Is it possible to access the other fields on the page in the validation?
Just checking, we want to be able to check several fields but how they are checked would happen as a group so would be handy if you can access the other fields.
thanks
Russ
I just want to check, having read the documentation I'm assuming the validation is for a single field? Is it possible to access the other fields on the page in the validation?
Just checking, we want to be able to check several fields but how they are checked would happen as a group so would be handy if you can access the other fields.
thanks
Russ
Please Log in or Create an account to join the conversation.
Moderators: Tuan Pham Ngoc
Support
Documentation
Information
Copyright © 2025 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.