PHP code example of setnemo / autogenerated-messages

1. Go to this page and download the library: Download setnemo/autogenerated-messages library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

setnemo / autogenerated-messages example snippets



declare(strict_types=1);
namespace Awesome\Requests;
use Illuminate\Foundation\Http\FormRequest;
class NewRequest extends FormRequest
{
    use DefaultMessages;  /** Add use trait */
    public function rules(): array
    {
        return [
            'name' => 'ersonal',
        ];
    }
}



var_export($newRequest->message());

[
  'name.tring' => 'Value for name must be string',
  'name.max' => 'Maximal value for name is 120',
  'start_date.
  'price.min' => 'Minimal value for price is 0',
  'pay_link.string' => 'Value for pay_link must be string',
  'pay_link.url' => 'Key pay_link must be valid url',
  'pay_link.max' => 'Maximal value for pay_link is 256',
  'video.mimes' => 'Allowed formats for video: mp4, mov, avi',
  'confidentiality.

[
    'nteger',
    'numeric',
    'string',
    'url',
    'in',
    'not_in',
    'min',
    'max',
    'mimes',
    'email',
    'unique',
    'json',
    'image',
    'accepted',
    'array',
    'boolean',
    'regex',
    'exists',
    'uuid',
    'after',
    'ip',
    'ipv4',
    'ipv6',
    'mac_address',
    'starts_with',
    'ends_with',
    'doesnt_start_with',
    'doesnt_end_with',
    'multiple_of',
    'same'
];


$this->addRuleNames(['test_rule']);
$this->addRulesToMessages(['test_rule' => 'test_message']);