protected function buildRuleWhenClient($type, $not = false)
    {
        $not = Json::encode($not);
        $types = Json::encode((array) $type);

        return new JsExpression("
            function (attribute, value) {
                var type = $(attribute.input).closest('.record-item').find('[data-attribute=type]');
                if (!type) return true;
                var types = $types;
                return $not !== (types.indexOf(type.val()) > -1);
            }
        ");
    }