Data validation is essential to any application, regardless of its size and purpose. Without it, you risk using data that's forged by malicious actors, contains only junk—or is a combination of both. And it doesn't matter where the data comes from either; whether from a web form, retrieved from a database, or read from an environment setting.
Gladly, validation is extremely common in modern software development, so much so that there are numerous third-party packages available on Packagist, and PHP's major frameworks all have a validation component. With them, you can validate email addresses, passwords, dates, IP addresses, numbers and so much more!
However, what happens when the package or framework doesn't support your use case, such as validating a phone number? In that case, you roll your own!
In this tutorial, we're going to build a custom Laravel validation rule object that validates a phone number from any country …
In the article Add a Click To Call Button & SMS Chat to Your Joomla Site, I presented a ready-to-use extension, XT Twilio for Joomla to implement a simple communication channel on a website. The basic extension sends SMS messages (or supports a Click2Call workflow) between users and the sales area. In the second article of this series, How to Customize a Joomla Extension for SMS Chat, I presented a case to add the client name field to the extension and personalize the SMS messaging.
In the world of Rails and Active Record, validating data and storing it in a database is easy. If you’d ever built a simple site that stores data in a Google Spreadsheet then you’d quickly learn that users can enter anything (or nothing). In this post we’ll see how to validate input using part of Active Record:
Spreadsheets can be databases too
In my last post we built a landing page for a new app using Sinatra and Google Spreadsheets as the database. The app needs one improvement though; users can enter any data they want in the form and it will happily submit. We need to guarantee we get some real data if we are going to contact our users when the app launches.
We should validate our input and ensure that
- We get at least a name and email address
- If we get an email …