Skip to content

Commit

Permalink
Remove Schema::isRequired()
Browse files Browse the repository at this point in the history
The validator provides this not the schema.
  • Loading branch information
markstory committed Dec 20, 2014
1 parent ff289fb commit ffd5d89
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
17 changes: 1 addition & 16 deletions src/Form/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Schema {
protected $_fieldDefaults = [
'type' => null,
'length' => null,
'precision' => null,
'required' => false,
];

Expand Down Expand Up @@ -100,22 +101,6 @@ public function field($name) {
return $this->_fields[$name];
}

/**
* Check whether or not a field is required.
*
* Fields that are not defined in the schema are not required.
*
* @param string $name The name of the field.
* @return bool Whether or not a field is required.
*/
public function isRequired($name) {
$field = $this->field($name);
if (!$field) {
return false;
}
return (bool) $field['required'];
}

/**
* Get the type of the named field.
*
Expand Down
18 changes: 0 additions & 18 deletions tests/TestCase/Form/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,6 @@ public function testRemovingFields() {
$this->assertNull($schema->field('name'));
}

/**
* test isRequired
*
* @return void
*/
public function testIsRequired() {
$schema = new Schema();

$schema->addField('name', ['type' => 'string'])
->addField('email', [
'type' => 'string',
'required' => true
]);
$this->assertFalse($schema->isRequired('name'));
$this->assertTrue($schema->isRequired('email'));
$this->assertFalse($schema->isRequired('nope'));
}

/**
* test fieldType
*
Expand Down

0 comments on commit ffd5d89

Please sign in to comment.