Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rename setRule to addRule #14

Closed
wants to merge 1 commit into from

2 participants

@harikt
Collaborator

Fixes issue #13 .

I have renamed setRule to addRule for in the discussion you mentioned about the change in name but with the same signature.

@pmjones
Owner

As noted in #13, it looks better to stay with setRule() at least for now. Sorry for the back-and-forth on this, and thanks for suggesting it.

@pmjones pmjones closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2013
  1. @harikt

    Rename setRule to addRule

    harikt authored
This page is out of date. Refresh to see the latest.
View
4 src/Aura/Input/Filter.php
@@ -25,7 +25,7 @@ class Filter implements FilterInterface
/**
*
- * Set Rule on a field
+ * Add Rule on a field
*
* @param string $field The field value
*
@@ -34,7 +34,7 @@ class Filter implements FilterInterface
* @param \Closure $closure A closure
*
*/
- public function setRule($field, $message, \Closure $closure)
+ public function addRule($field, $message, \Closure $closure)
{
$this->rules[$field][] = [$message, $closure];
}
View
4 src/Aura/Input/FilterInterface.php
@@ -21,7 +21,7 @@
{
/**
*
- * Set Rule on a field
+ * Add Rule on a field
*
* @param string $field The field value
*
@@ -30,7 +30,7 @@
* @param \Closure $closure A closure
*
*/
- public function setRule($field, $message, \Closure $closure);
+ public function addRule($field, $message, \Closure $closure);
/**
*
View
6 tests/Aura/Input/FilterTest.php
@@ -10,17 +10,17 @@ protected function setUp()
$this->filter = new Filter;
// validate
- $this->filter->setRule('foo', 'Foo should be alpha only', function ($value) {
+ $this->filter->addRule('foo', 'Foo should be alpha only', function ($value) {
return ctype_alpha($value);
});
- $this->filter->setRule('foo', 'Foo should be more than 7 characters', function ($value) {
+ $this->filter->addRule('foo', 'Foo should be more than 7 characters', function ($value) {
$length = strlen($value);
return ($length > 7);
});
// sanitize
- $this->filter->setRule('bar', 'Remove non-alpha from bar', function (&$value) {
+ $this->filter->addRule('bar', 'Remove non-alpha from bar', function (&$value) {
$value = preg_replace('/[^a-z]/i', '!', $value);
return true;
});
View
2  tests/Aura/Input/FormTest.php
@@ -100,7 +100,7 @@ public function testFilter()
$form->setField('bar', 'text');
$filter = $form->getFilter();
- $filter->setRule('foo', 'Foo should be alpha', function ($value) {
+ $filter->addRule('foo', 'Foo should be alpha', function ($value) {
return ctype_alpha($value);
});
Something went wrong with that request. Please try again.