validate method

bool validate(
  1. SchemaDocument doc
)

Validates if all fields of the provided doc match the Schema fields.

Implementation

bool validate(SchemaDocument doc) {
  if (doc.schemaDid != did) {
    return false;
  }
  if (doc.fields.length != fields.length) {
    return false;
  }
  for (var i = 0; i < fields.length; i++) {
    if (fields[i].name != doc.fields[i].key) {
      return false;
    }
    if (fields[i].fieldKind.kind != doc.fields[i].kind) {
      return false;
    }
  }
  return true;
}