Assert\Assertion::ip PHP Метод

ip() публичный статический Метод

Assert that value is an IPv4 or IPv6 address (using input_filter/FILTER_VALIDATE_IP).
public static ip ( string $value, null | integer $flag = null, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$flag null | integer
$message string | null
$propertyPath string | null
Результат boolean
    public static function ip($value, $flag = null, $message = null, $propertyPath = null)
    {
        self::string($value, $message, $propertyPath);
        if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) {
            $message = sprintf($message ?: 'Value "%s" was expected to be a valid IP address.', self::stringify($value));
            throw static::createException($value, $message, static::INVALID_IP, $propertyPath);
        }
        return true;
    }