Skip to content

Commit

Permalink
Merge pull request #3 from TiagoSilvaPereira/patch-1
Browse files Browse the repository at this point in the history
Adding a simple way to define custom Filters
  • Loading branch information
sildraug authored Apr 11, 2017
2 parents b05ea79 + 0eb53c7 commit 02557d3
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Laravel/SanitizesInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,23 @@ public function validate()
*/
public function sanitize()
{
$this->addCustomFilters();
$this->sanitizer = \Sanitizer::make($this->input(), $this->filters());
$this->replace($this->sanitizer->sanitize());
}

/**
* Add custom fields to the Sanitizer
*
* @return void
*/
public function addCustomFilters()
{
foreach ($this->customFilters() as $name => $filter) {
\Sanitizer::extend($name, $filter);
}
}

/**
* Filters to be applied to the input.
*
Expand All @@ -35,4 +48,14 @@ public function filters()
{
return [];
}
}

/**
* Custom Filters to be applied to the input.
*
* @return void
*/
public function customFilters()
{
return [];
}
}

0 comments on commit 02557d3

Please sign in to comment.