validate method

void validate()

Validates option invariants (used by QS.decode and direct decoder calls).

Implementation

void validate() {
  if (_validated[this] == true) return;

  final Encoding currentCharset = charset;
  if (currentCharset != utf8 && currentCharset != latin1) {
    throw ArgumentError.value(currentCharset, 'charset', 'Invalid charset');
  }

  if (decodeDotInKeys && !allowDots) {
    throw ArgumentError.value(
      decodeDotInKeys,
      'decodeDotInKeys',
      'Invalid combination: decodeDotInKeys=$decodeDotInKeys requires '
          'allowDots=true (currently allowDots=$allowDots).',
    );
  }

  final num limit = parameterLimit;
  if (limit.isNaN || limit <= 0) {
    throw ArgumentError.value(
      limit,
      'parameterLimit',
      'Parameter limit must be a positive number.',
    );
  }

  _validated[this] = true;
}