updateGroupRequestValidator function

void updateGroupRequestValidator(
  1. String chatId,
  2. String groupName,
  3. String groupDescription,
  4. String? groupImage,
  5. List<String> members,
  6. List<String> admins,
  7. String address,
)

Implementation

void updateGroupRequestValidator(
  String chatId,
  String groupName,
  String groupDescription,
  String? groupImage,
  List<String> members,
  List<String> admins,
  String address,
) {
  if (chatId.isEmpty) {
    throw Exception('chatId cannot be null or empty');
  }

  if (groupName.isEmpty) {
    throw Exception('groupName cannot be null or empty');
  }

  if (groupName.length > 50) {
    throw Exception('groupName cannot be more than 50 characters');
  }

  if (groupDescription.length > 150) {
    throw Exception('groupDescription cannot be more than 150 characters');
  }

  if (members.isNotEmpty) {
    for (int i = 0; i < members.length; i++) {
      if (!isValidETHAddress(members[i])) {
        throw Exception('Invalid member address in members list!');
      }
    }
  }

  if (admins.isNotEmpty) {
    for (int i = 0; i < admins.length; i++) {
      if (!isValidETHAddress(admins[i])) {
        throw Exception('Invalid member address in admins list!');
      }
    }
  }

  if (!isValidETHAddress(address)) {
    throw Exception('Invalid address field!');
  }
}