Welcome Guest, Not a member yet? Register   Sign In
Diffrerent rorrs with one validator
#3

(This post was last modified: 12-11-2022, 03:26 PM by motoroller.)

(12-11-2022, 02:23 PM)datamweb Wrote: Hi,
You can display the desired error for any condition. For more information, see the link below:

https://github.com/datamweb/codeIgniter-...hp#L33-L43

public function validDateCompare (string $dateStart, string $dateEnd, string &$error = null): bool {

// Формируем объекты даты
$DateStart = (new DateTime($dateStart));
$DateEnd = (new DateTime($dateEnd));

if($DateStart > $DateEnd) {
$error = 'New message of erros';
return false;
}

return true;

}


any way i got error from Name of validator (validDateCompare )

(12-11-2022, 03:09 PM)motoroller Wrote:
(12-11-2022, 02:23 PM)datamweb Wrote: Hi,
You can display the desired error for any condition. For more information, see the link below:

https://github.com/datamweb/codeIgniter-...hp#L33-L43

public function validDateCompare (string $dateStart, string $dateEnd, string &$error = null): bool {

        // Формируем объекты даты
        $DateStart = (new DateTime($dateStart));
        $DateEnd  = (new DateTime($dateEnd));

        if($DateStart > $DateEnd) {
            $error = 'New message of erros';
            return false;
        }

        return true;

    }


any way i got error from Name of validator (validDateCompare )

Sulution Code

public function validDatesReport (string $value, string $fields, array $Data, &$error = null): bool {

$DateStart = (new DateTime($Data['dateStart']));
$DateEnd = (new DateTime($Data['dateEnd']));


if($DateStart > $DateEnd) {
$error = lang('Validation.validDateCompare');
return false;
}

if($DateStart->diff($DateEnd)->format('%a') > 186) {
$error = lang('Validation.validDateDifference');
return false;
}

return true;

}
Reply


Messages In This Thread
RE: Diffrerent rorrs with one validator - by motoroller - 12-11-2022, 03:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB