Welcome Guest, Not a member yet? Register   Sign In
Argument Types for Validation Rules
#1

I created the following validation rule:

Code:
public function not_blocked(int $mebn_seq): bool
{
    return !(new MebnDb())->isBlocked($mebn_seq);
}

It errored because $mebn_seq is declat=red as int. I had to declare it as string and cast the argument to isBlocked:

Code:
public function not_blocked(string $mebn_seq): bool
{
    return !(new MebnDb())->isBlocked((int)$mebn_seq);
}

I do not believe I should have to do this. I created an issue in GitHub.
Simpler is always better
Reply
#2

What error do you see?
Error message, stack trace?
Reply
#3

The data of the incoming request is by default a string.
This is not a framework or php problem. This is a problem with the HTTP protocol.
Reply
#4

(12-18-2021, 05:03 AM)iRedds Wrote: The data of the incoming request is by default a string.
This is not a framework or php problem. This is a problem with the HTTP protocol.

Oh, so validation rule functions must always use string as a type for their parameters.
Simpler is always better
Reply




Theme © iAndrew 2016 - Forum software by © MyBB