Skip to content

Commit

Permalink
chore: fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Nov 4, 2024
1 parent 6d72c3e commit f32942e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public function validate(array $dataSource, array $validationSet)
public function addRule(string $name, $handler, ?string $message = null)
{
$this->rules[strtolower($name)] = $handler;
$this->messages[strtolower($name)] = $message ?? "%s is invalid!";
$this->messages[strtolower($name)] = $message ?? '%s is invalid!';
}

/**
Expand All @@ -312,11 +312,11 @@ public function addErrorMessage($field, ?string $message = null)
return $this->addMessage($field, $message);
}

/**
* Add validation error message
* @param string|array $field The field to add the message to
* @param string|null $message The error message if $field is a string
*/
/**
* Add validation error message
* @param string|array $field The field to add the message to
* @param string|null $message The error message if $field is a string
*/
public function addMessage($field, ?string $message = null)
{
if (is_array($field)) {
Expand All @@ -342,7 +342,7 @@ public function submit(string $method, string $action, array $fields)
$form_fields = '';

foreach ($fields as $key => $value) {
$form_fields = $form_fields . "<input type=\"hidden\" name=\"$key\" value=" . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . ">";
$form_fields = $form_fields . "<input type=\"hidden\" name=\"$key\" value=" . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '>';
}

echo "
Expand Down
3 changes: 2 additions & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public static function get()
}
}

function validator() {
function validator()
{
if (!Cache::get()) {
Cache::set(new \Leaf\Form());
}
Expand Down
1 change: 0 additions & 1 deletion tests/message.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use Leaf\Form;

test('message can be set for a rule', function () {
validator()->message('number', 'This is a custom message');
Expand Down
1 change: 0 additions & 1 deletion tests/validation.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use Leaf\Form;

test('can perform inline validation', function () {
$value = '';
Expand Down

0 comments on commit f32942e

Please sign in to comment.