Skip to content

Commit

Permalink
Code reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlpp committed Mar 24, 2016
1 parent 8732960 commit 6b59d86
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/Dvlpp/Sharp/Validation/SharpValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Dvlpp\Sharp\Validation;

use Validator;
use Dvlpp\Sharp\Exceptions\ValidationException;
use Validator;

/**
* Class SharpValidator
Expand Down Expand Up @@ -49,15 +49,15 @@ public function validate($input, $instanceId = null)
{
$this->instanceId = $instanceId;

// Grab rules
// Grab rules,
$rules = array_merge($this->getRules(),
$this->getInstanceId() ? $this->getUpdateRules() : $this->getCreationRules()
);

// Sanitize ?
// sanitize if needed,
$input = $this->sanitize($input);

// and validate
// and validate.
$validation = Validator::make($input, $rules, $this->getMessages());

if ($validation->fails()) {
Expand All @@ -67,36 +67,58 @@ public function validate($input, $instanceId = null)
return $input;
}

/**
* @return bool
*/
public function isCreation()
{
return $this->instanceId == null;
}

/**
* @return mixed
*/
public function getInstanceId()
{
return $this->instanceId;
}

/**
* @return array
*/
public function getUpdateRules()
{
return $this->updateRules;
}

/**
* @return array
*/
public function getCreationRules()
{
return $this->creationRules;
}

/**
* @return array
*/
public function getRules()
{
return $this->rules;
}

/**
* @return array
*/
public function getMessages()
{
return $this->messages;
}

/**
* @param array $input
* @return array
*/
public function sanitize(Array $input)
{
return $input;
Expand Down

0 comments on commit 6b59d86

Please sign in to comment.