The Streams platform provides a simple interface to leverage Laravel's own validation. Please make sure you are familiar with basic Laravel validation before proceeding.
The Streams platform leans heavily on native Laravel validation, streamlines the process, and allows flexibility to adjust this behavior entirely.
All Streams rule configurations are defined as an array of rules on the field in which they apply to.
You may define rules whithin the field configuration:
// streams/contacts.json
{
"fields": {
"name": {
"type": "string",
"rules": ["required", "max:100"]
},
"email": {
"type": "email",
"rules": ["unique", "required"]
},
"company": {
"type": "relationship",
"config": {
"related": "companies"
},
"rules": ["required"]
}
}
}
You may also define custom validation rules for fields.
// streams/contacts.json
{
"fields": {
"name": {
"type": "string",
"rules": [
"required",
"App\\Rules\\Example"
]
}
}
}
Being that data validation is a fundamental principle, all validation typically operates around the domain objects.
You can return a pre-loaded validator instance directly from the entry itself.
use Streams\Core\Support\Facades\Streams;
$entry = Streams::repository('contacts')->find('john-doe');
if ($entry->validator()->passes()) {
// Yay!
}
You may also return a validator instance with your own data which can be an entry object or array of data to validate as an entry.
use Streams\Core\Support\Facades\Streams;
$validator = Streams::repository('contacts')->validator([
'name' => 'John Doe',
'email' => '[email protected]',
'company' => 'streams',
]);
if ($entry->validator()->passes()) {
// Yay!
}
A blank TALL-stack Laravel project with Streams.
The fundamental features and utilities offered by the Streams platform.
A universal and extensible RESTful API for Streams.
Extensible, user-friendly, and performant control panel, components, and services.
Dev tooling for Laravel Streams.