validate method

Map<String, dynamic> validate()

Implementation

Map<String, dynamic> validate() {
  // check for the id length
  int idSize = utf8.encode(id).length;
  if (idSize > DocRestrictions.maxIdLength) {
    throw DbDocValidationException(
        '${DBRKeys.id} max length is ${DocRestrictions.maxIdLength} bytes');
  }
  // checking for the _collections keyword
  if (doc[DBRKeys.collections] != null) {
    throw DbDocValidationException(
        'you can\'t use ${DBRKeys.collections} keyword as it is reserved');
  }
  // update the id
  doc[DBRKeys.id] = id;
  // doc[DBRKeys.collections] = [];
  return doc;
}