mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Custom validation rule for amount
This commit is contained in:
parent
2bc8146f7c
commit
7a267b4406
39
app/Http/ValidationRules/ValidAmount.php
Normal file
39
app/Http/ValidationRules/ValidAmount.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
@ -4334,6 +4334,7 @@ $LANG = array(
|
|||||||
'clone_to_expense' => 'Clone to expense',
|
'clone_to_expense' => 'Clone to expense',
|
||||||
'checkout' => 'Checkout',
|
'checkout' => 'Checkout',
|
||||||
'acss' => 'Pre-authorized debit payments',
|
'acss' => 'Pre-authorized debit payments',
|
||||||
|
'invalid_amount' => 'Invalid amount. Number/Decimal values only.'
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user