Validating Blade Directives
Learn about our new validation helpers and add them to the Blade directive class.
We'll cover the following
In this lesson, we will work to implement a Blade directive validation system. Our validation system will allow developers to specify arbitrary callback functions that will be used to determine if a directive is valid or not. We will also use this system internally to support the default validators. Our validation functions will indicate an issue if they return a string, and returning nothing will mean that the directive passed that particular validation rule.
Beginning the validator implementation
To begin, we will add our $validators
array and our addValidator
method:
Get hands-on with 1400+ tech skills courses.