ensureLegality static method

bool ensureLegality({
  1. required List<String> columns,
  2. required List<Object?> values,
})

Utils

Implementation

static bool ensureLegality({required List<String> columns, required List<Object?> values}) {
  assert(columns.length == values.length, '[BoxerOptions] ERROR: column & value size not the same!');
  List<String> copy = List<String>.from(columns);
  copy.removeWhere((e) => e.trim().isEmpty);
  assert(columns.length == copy.length, '[BoxerOptions] ERROR: column list contains empty string!');
  bool illegal = columns.length != values.length || columns.length != copy.length;

  // remove the empty column and corresponding value
  List<String> temp = List<String>.from(columns);
  for (int i = temp.length - 1; i >= 0; i--) {
    if (temp[i].trim().isEmpty) {
      columns.remove(i);
      values.remove(i);
    }
  }
  return illegal;
}