HolderSubjectConstraint.fromJson constructor

HolderSubjectConstraint.fromJson(
  1. dynamic isHolderObject
)

Implementation

HolderSubjectConstraint.fromJson(dynamic isHolderObject) {
  Map<String, dynamic> ih = credentialToMap(isHolderObject);
  if (ih.containsKey('field_id')) {
    fieldId = ih['field_id'].cast<String>();
  } else {
    throw FormatException(
        'field_id property is required for is_holder Object');
  }

  if (ih.containsKey('directive')) {
    String value = ih['directive'];
    if (value == 'preferred') {
      directive = Limiting.preferred;
    } else if (value == 'required') {
      directive = Limiting.required;
    } else {
      throw Exception('Unknown value for directive property');
    }
  } else {
    throw FormatException(
        'directive property is required for is_holder object');
  }
}