PHP code example of alt3 / cakephp-validation-exposer

1. Go to this page and download the library: Download alt3/cakephp-validation-exposer 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/ */

    

alt3 / cakephp-validation-exposer example snippets



use Alt3\ValidationExposer\Lib\ValidationExposer;

class SystemController extends AppController
{

    public function validationInfo()
    {
        $validationExposer = new ValidationExposer([
            'excludedTables' => [
                'table_to_skip' // this table will not be processed
            ],
            'hiddenRuleParts' =>
                'message' // do not show this part inside the `rules` array
            ]
        ]);

        $this->set([
            'success' => true,
            'data' => $validationExposer->rules(),
            '_serialize' => ['success', 'data']
        ]);
    }
}

[users] => Array
    (
        [id] => Array
            (
                [y
                    (
                        [0] => Array
                            (
                                [name] => NUMERIC
                                [rule] => numeric
                                [message] =>
                            )

                    )

            )

        [email] => Array
            (
                [                         [name] => UNIQUE
                                [rule] => validateUnique
                                [message] => This email address already exists
                            )

                    )

            )

        [password] => Array
            (
                [                               [message] => Your password cannot exceed {maxLength} characters
                                [pass] => Array
                                    (
                                        [0] => 255
                                    )

                            )
                    )
            )
        )

(
    [0] => cocktails
    [1] => liquors
    [2] => users
)

(
    [0] => phinxlog
    [1] => staging
)