validation of integer and unique values
validation of integer and unique values
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
I use editor and have a column which must be integer and unique.
I set in the column attributes:
label: "",
name: "",
attr: {
type: 'number',
min: 1,
max: 999,
step: 1
}
on the server side controller I set :
validator(Validate::unique(ValidateOptions::inst()
->message('number already exists')))
and a custom validation to validate only integer number:
->validator(function ($val, $data, $opts) {
if ($val === null) {
return true;
} else if (!is_numeric($val) || !is_int(intval($val))) {
return 'Number must be integer';
}
})
If a enter an integer number which already exists, the unique validation works fine and advice that number exists.
But If I enter a decimal number (example 7.5) and the integer part exists (number 7 already exists) them the input is truncated to 7 (only integers are accepted) but the unique validation is not triggered.
Is there any solution for that?
thanks in advance
Answers
sorry, forget the above. I was converting to integer before testing if integer