validateDirectedOutInOut function

void validateDirectedOutInOut(
  1. ParamDirection direction,
  2. ParamValue pv
)

Client-side checks for DRT1 OUT / INOUT that the native engine will reject; fails fast with the same slugs as output_aware_params.rs.

Implementation

void validateDirectedOutInOut(ParamDirection direction, ParamValue pv) {
  if (direction == ParamDirection.input) {
    return;
  }
  if (pv is ParamValueRefCursorOut) {
    if (direction != ParamDirection.output) {
      throw ArgumentError.value(
        pv,
        'value',
        _directedParamMessage(
          _refCursorInvalidDirectionSlug,
          'ParamValueRefCursorOut is only valid for ParamDirection.output',
        ),
      );
    }
    return;
  }
  if (pv is ParamValueBinary) {
    throw ArgumentError.value(
      pv,
      'value',
      _directedParamMessage(
        _binaryOutInOutNotImplementedSlug,
        'OUT/INOUT for binary columns is not implemented; use Integer, '
        'BigInt, String, or Decimal (see TYPE_MAPPING ยง3.1)',
      ),
    );
  }
  if (pv is ParamValueNull) {
    if (direction == ParamDirection.inOut) {
      throw ArgumentError.value(
        pv,
        'value',
        _directedParamMessage(
          _inOutNullSlug,
          'INOUT with ParamValueNull is not supported; pass Integer, BigInt, '
          'String, or non-empty Decimal',
        ),
      );
    }
    return;
  }
  if (pv is ParamValueDecimal) {
    if (pv.value.isEmpty) {
      throw ArgumentError.value(
        pv,
        'value',
        _directedParamMessage(
          _decimalOutInOutRequiresNonEmptySlug,
          'use a non-empty ParamValue::Decimal for OUT/INOUT or use String',
        ),
      );
    }
  }
}