Generate default validation rules.
public getValidation ( |
||
$model | The model to introspect. | |
$associations | array | The associations list. |
return | array | The validation rules. |
/** * test getting validation rules and exempting foreign keys * * @return void */ public function testGetValidationExcludeForeignKeys() { $model = TableRegistry::get('BakeArticles'); $associations = ['belongsTo' => ['BakeUsers' => ['foreignKey' => 'bake_user_id']]]; $result = $this->Task->getValidation($model, $associations); $expected = ['title' => ['valid' => ['rule' => false, 'allowEmpty' => false]], 'body' => ['valid' => ['rule' => false, 'allowEmpty' => true]], 'published' => ['valid' => ['rule' => 'boolean', 'allowEmpty' => true]], 'id' => ['valid' => ['rule' => 'integer', 'allowEmpty' => 'create']]]; $this->assertEquals($expected, $result); }