validate static method

bool validate(
  1. dynamic data
)

Implementation

static bool validate(data) {
  if (data['type'] != 'MultiLineString' || !(data['coordinates'] is List)) {
    return false;
  }

  List multiLine = data['coordinates'];
  for (var i = 0; i < multiLine.length; i++) {
    if (!(multiLine[i] is List)) {
      return false;
    }
    List line = multiLine[i];

    for (var j = 0; j < line.length; j++) {
      var point = line[j];
      if (!(point[0] is num && point[1] is num)) {
        return false;
      }
    }
  }

  return true;
}