|
<?php |
|
|
|
use Tests\Concerns\RequestDataProviderItem; |
|
|
|
dataset('application create', [ |
|
'UUID is required' => [ |
|
new RequestDataProviderItem() |
|
->attribute('uuid') |
|
->empty() |
|
->assertError('The uuid field is required.'), |
|
], |
|
'UUID must be a UUID' => [ |
|
new RequestDataProviderItem() |
|
->attribute('uuid') |
|
->string(5) |
|
->assertError('The uuid field must be a valid UUID.'), |
|
], |
|
|
|
'Title is required' => [ |
|
new RequestDataProviderItem() |
|
->attribute('title') |
|
->empty() |
|
->assertError('The title field is required.'), |
|
], |
|
'Title must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('title') |
|
->array(1) |
|
->assertError('The title field must be a string.'), |
|
], |
|
'Title must be <= 100 characters' => [ |
|
new RequestDataProviderItem() |
|
->attribute('title') |
|
->string(101) |
|
->assertError('The title field must not be greater than 100 characters.'), |
|
], |
|
|
|
'Email is required' => [ |
|
new RequestDataProviderItem() |
|
->attribute('email') |
|
->empty() |
|
->assertError('The email field is required.'), |
|
], |
|
'Email must be <= 255 characters' => [ |
|
new RequestDataProviderItem() |
|
->attribute('email') |
|
->string(256) |
|
->assertError('The email field must not be greater than 255 characters.'), |
|
], |
|
'Email must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('email') |
|
->array(1) |
|
->assertError('The email field must be a string.'), |
|
], |
|
'Email must be an email' => [ |
|
new RequestDataProviderItem() |
|
->attribute('email') |
|
->email(valid: false) |
|
->assertError('You must provide a real functioning email address.'), |
|
], |
|
|
|
'DOB must be a date' => [ |
|
new RequestDataProviderItem() |
|
->attribute('dob') |
|
->string(5) |
|
->assertError('The dob field must match the format Y-m-d.'), |
|
], |
|
'DOB must adhere to a specific format' => [ |
|
new RequestDataProviderItem() |
|
->attribute('dob') |
|
->date('d-m-Y') |
|
->assertError('The dob field must match the format Y-m-d.'), |
|
], |
|
|
|
'Address must be an array' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses') |
|
->string(5) |
|
->assertError('The addresses field must be an array.'), |
|
], |
|
'Address must have not have more than 25 items' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses') |
|
->array(26) |
|
->assertError('The addresses field must not have more than 25 items.'), |
|
], |
|
|
|
'Address address1 is required' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.address1') |
|
->empty() |
|
->assertError('The address line 1 field is required.'), |
|
], |
|
'Address address1 must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.address1') |
|
->array(1) |
|
->assertError('The address line 1 field must be a string.'), |
|
], |
|
'Address address1 must be <= 255 characters' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.address1') |
|
->string(256) |
|
->assertError('The address line 1 field must not be greater than 255 characters.'), |
|
], |
|
|
|
'Address address2 must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.address2') |
|
->array(1) |
|
->assertError('The address line 2 field must be a string.'), |
|
], |
|
'Address address2 must be <= 255 characters' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.address2') |
|
->string(256) |
|
->assertError('The address line 2 field must not be greater than 255 characters.'), |
|
], |
|
|
|
'Address address3 must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.address3') |
|
->array(1) |
|
->assertError('The address line 3 field must be a string.'), |
|
], |
|
'Address address3 must be <= 255 characters' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.address3') |
|
->string(256) |
|
->assertError('The address line 3 field must not be greater than 255 characters.'), |
|
], |
|
|
|
'Address town is required' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.town') |
|
->empty() |
|
->assertError('The address town field is required.'), |
|
], |
|
'Address town must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.town') |
|
->array(1) |
|
->assertError('The address town field must be a string.'), |
|
], |
|
'Address town must be <= 255 characters' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.town') |
|
->string(256) |
|
->assertError('The address town field must not be greater than 255 characters.'), |
|
], |
|
|
|
'Address county is required' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.county') |
|
->empty() |
|
->assertError('The address county field is required.'), |
|
], |
|
'Address county must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.county') |
|
->array(1) |
|
->assertError('The address county field must be a string.'), |
|
], |
|
'Address county must be <= 255 characters' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.county') |
|
->string(256) |
|
->assertError('The address county field must not be greater than 255 characters.'), |
|
], |
|
|
|
'Address postcode is required' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.postcode') |
|
->empty() |
|
->assertError('The address postcode field is required.'), |
|
], |
|
'Address postcode must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.postcode') |
|
->array(1) |
|
->assertError('The address postcode field must be a string.'), |
|
], |
|
'Address postcode must be <= 20 characters' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.postcode') |
|
->string(21) |
|
->assertError('The address postcode field must not be greater than 20 characters.'), |
|
], |
|
'Address postcode must a valid postcode' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.postcode') |
|
->value('NR1 DDD') |
|
->assertError('The postcode field is invalid.'), |
|
], |
|
|
|
'Address country is required' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.country') |
|
->empty() |
|
->assertError('The address country field is required.'), |
|
], |
|
'Address country must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.country') |
|
->array(1) |
|
->assertError('The address country field must be a string.'), |
|
], |
|
'Address country must be <= 255 characters' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.country') |
|
->string(256) |
|
->assertError('The address country field must not be greater than 255 characters.'), |
|
], |
|
|
|
'Address from date must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.from_date') |
|
->array(1) |
|
->assertError('The address from-date field must be a string.'), |
|
], |
|
'Address from date must be a date' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.from_date') |
|
->string(5) |
|
->assertError('The address from-date field must match the format Y-m-d.'), |
|
], |
|
'Address from date must adhere to a specific format' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.from_date') |
|
->date('d-m-Y') |
|
->assertError('The address from-date field must match the format Y-m-d.'), |
|
], |
|
'Address from date must be before tomorrow' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.from_date') |
|
->value(now()->addDays(2)->format('Y-m-d')) |
|
->assertError('The address from-date field must be a date before tomorrow.'), |
|
], |
|
|
|
'Address to-date must be a string' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.to_date') |
|
->array(1) |
|
->assertError('The address to-date field must be a string.'), |
|
], |
|
'Address to-date must be a date' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.to_date') |
|
->string(5) |
|
->assertError('The address to-date field must match the format Y-m-d.'), |
|
], |
|
'Address to-date must adhere to a specific format' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.to_date') |
|
->date('d-m-Y') |
|
->assertError('The address to-date field must match the format Y-m-d.'), |
|
], |
|
'Address to-date must be before tomorrow' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.to_date') |
|
->value(now()->addDays(2)->format('Y-m-d')) |
|
->assertError('The address to-date field must be a date before tomorrow.'), |
|
], |
|
'Address to-date must be after the linked from date' => [ |
|
new RequestDataProviderItem() |
|
->attribute('addresses.0.to_date') |
|
->value(now()->subDays(5)->format('Y-m-d')) |
|
->with([ |
|
'addresses' => [ |
|
[ |
|
'from_date' => now()->subDays(2)->format('Y-m-d'), |
|
], |
|
], |
|
]) |
|
->assertError('The address to-date field must be a date after address from-date.'), |
|
], |
|
]); |
I like this, what might be good though is pulling the validation messages from the lang file maybe.