castable as

Attempts to make invalid casts, for example string to integer, will raise dynamic errors. The castable as operator allows you to test if the cast will succeed.

$x castable as eg:HatSize

returns true if the value of $x can be cast to eg:HatSize.