blob: 06a290f7115aece0e4fad647c24670870f2a4c84 [file] [log] [blame]
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:convert';
/// Throw if the given close code is not valid.
void checkCloseCode(int? code) {
if (code != null) {
RangeError.checkValueInInterval(code, 3000, 4999, 'code');
}
}
/// Throw if the given close reason is not valid.
void checkCloseReason(String? reason) {
if (reason != null && utf8.encode(reason).length > 123) {
throw ArgumentError.value(reason, 'reason',
'reason must be <= 123 bytes long when encoded as UTF-8');
}
}