1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Custom validation rule for amount

This commit is contained in:
David Bomba 2021-10-23 10:16:43 +11:00
parent 2bc8146f7c
commit 7a267b4406
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,39 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\ValidationRules;
use App\Libraries\MultiDB;
use Illuminate\Contracts\Validation\Rule;
/**
* Class ValidAmount.
*/
class ValidAmount implements Rule
{
/**
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
return (bool) is_float($value) || is_int($value);
}
/**
* @return string
*/
public function message()
{
return ctrans('texts.invalid_amount');
}
}

View File

@ -4334,6 +4334,7 @@ $LANG = array(
'clone_to_expense' => 'Clone to expense',
'checkout' => 'Checkout',
'acss' => 'Pre-authorized debit payments',
'invalid_amount' => 'Invalid amount. Number/Decimal values only.'
);
return $LANG;