-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ushahidi/kohana-validation package and use that
This replaces the dependencies on Kohana Core. - Update Validators to refer to namespaced Valid and Validation class - Fix DI for ValidationEngineTrait - Set up translations - Move error messages to laravel language files
- Loading branch information
Showing
36 changed files
with
194 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
application/messages/form_attribute.php → resources/lang/en/form_attribute.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
application/messages/form_role.php → resources/lang/en/form_role.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php defined('SYSPATH') OR die('No direct script access.'); | ||
<?php | ||
|
||
return [ | ||
'roles' => [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
application/messages/message.php → resources/lang/en/message.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php defined('SYSPATH') OR die('No direct script access.'); | ||
<?php | ||
|
||
return [ | ||
'contact' => [ | ||
|
2 changes: 1 addition & 1 deletion
2
application/messages/notifications.php → resources/lang/en/notifications.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php defined('SYSPATH') OR die('No direct script access.'); | ||
<?php | ||
|
||
return [ | ||
'email' => [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
<?php defined('SYSPATH') OR die('No direct script access.'); | ||
<?php | ||
|
||
return array( | ||
'isSlugAvailable' => ':field :value is already in use', | ||
'description.regex' => 'The description must contain only letters, numbers, spaces and punctuation', | ||
'tag.regex' => 'The category name must contain only letters, numbers, spaces and punctuation', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php defined('SYSPATH') or die('No direct script access.'); | ||
|
||
return array( | ||
|
||
'alpha' => ':field must contain only letters', | ||
'alpha_dash' => ':field must contain only numbers, letters and dashes', | ||
'alpha_numeric' => ':field must contain only letters and numbers', | ||
'color' => ':field must be a color', | ||
'credit_card' => ':field must be a credit card number', | ||
'date' => ':field must be a date', | ||
'decimal' => ':field must be a decimal with :param2 places', | ||
'digit' => ':field must be a digit', | ||
'email' => ':field must be an email address', | ||
'email_domain' => ':field must contain a valid email domain', | ||
'equals' => ':field must equal :param2', | ||
'exact_length' => ':field must be exactly :param2 characters long', | ||
'in_array' => ':field must be one of the available options', | ||
'ip' => ':field must be an ip address', | ||
'matches' => ':field must be the same as :param3', | ||
'min_length' => ':field must be at least :param2 characters long', | ||
'max_length' => ':field must not exceed :param2 characters long', | ||
'not_empty' => ':field must not be empty', | ||
'numeric' => ':field must be numeric', | ||
'phone' => ':field must be a phone number', | ||
'range' => ':field must be within the range of :param2 to :param3', | ||
'regex' => ':field does not match the required format', | ||
'url' => ':field must be a url', | ||
|
||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace Ushahidi\App\Validator; | ||
|
||
/** | ||
* Ushahidi Core Validation Tool | ||
* | ||
* @author Ushahidi Team <team@ushahidi.com> | ||
* @package Ushahidi\Core | ||
* @copyright 2014 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html | ||
* GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
use Kohana\Validation\Validation as KohanaValidation; | ||
use Ushahidi\Core\Tool\ValidationEngine; | ||
use Illuminate\Contracts\Translation\Translator; | ||
|
||
class KohanaValidationEngine extends KohanaValidation implements ValidationEngine | ||
{ | ||
/** | ||
* @var TranslatorContract | ||
*/ | ||
private $translator; | ||
|
||
public function __construct(Translator $translator) | ||
{ | ||
$this->translator = $translator; | ||
|
||
parent::__construct([], $this->getTranslationCallback()); | ||
} | ||
|
||
public function getTranslationCallback() | ||
{ | ||
return function ($file, $field, $error = null) { | ||
if ($error) { | ||
return $this->translator->has("$file.$field.$error") ? | ||
$this->translator->trans("$file.$field.$error") : false; | ||
} else { | ||
return $this->translator->has("$file.$field") ? | ||
$this->translator->trans("$file.$field") : false; | ||
} | ||
}; | ||
} | ||
|
||
public function setData(array $data) | ||
{ | ||
$this->_data = $data; | ||
} | ||
|
||
public function getData($key = null) | ||
{ | ||
if ($key === null) { | ||
return $this->_data; | ||
} | ||
|
||
if (array_key_exists($key, $this->_data)) { | ||
return $this->_data[$key]; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public function setFullData(array $fullData) | ||
{ | ||
$this->bind(':fulldata', $fullData); | ||
} | ||
|
||
public function getFullData($key = null) | ||
{ | ||
if ($key === null) { | ||
return $this->_bound[':fulldata']; | ||
} | ||
|
||
if (array_key_exists($key, $this->_bound[':fulldata'])) { | ||
return $this->_bound[':fulldata'][$key]; | ||
} | ||
|
||
return null; | ||
} | ||
} |
Oops, something went wrong.