module entertainment-facilities-zoo {
  namespace "http://example.com/ns/entertainment-facilities-zoo";
  prefix ef-zoo;
  import ietf-direct-must-augment-extension
    { prefix direct-must-augment-ex; }
  import entertainment-facilities { prefix ef; }
  organization "Example, Inc.";
  contact "support@example.com";

  description
    "Module used in DIRECT-MUST-AUGMENT-EX example. " +
    "Defines entertainment facility of type zoo where" +
    "no children without adult supervision are allowed.";

  revision 2015-06-12 {
    description "Initial version";
  }

  identity zoo {
    base ef:entertainment-facility-generic;
  }
  augment
    "/ef:entertainment-facilities/ef:entertainment-facility" {
    when "ef:type='ef-zoo:zoo'";
    list child-supervision {
      key child;
      leaf child {
        type leafref {
          path "../../ef:visitor";
        }
        must "/people/person[name=current()]/age<=14" {
          error-message
            "People older then 14 are not children.";
        }
      }
      leaf adult {
        mandatory true;
        type leafref {
          path "../../ef:visitor";
        }
        must "/people/person[name=current()]/age>=18" {
          error-message
            "People younger then 18 are not adults.";
        }
      }
    }
  }

  direct-must-augment-ex:augment
    "/ef:entertainment-facilities/ef:entertainment-facility/" +
    "ef:visitor" {
    when "../ef:type='ef-zoo:zoo'";
    must "((../child-supervision[child=current()]) or
          (/people/person[name=current()]/age>=14))" {
      error-message
        "Children without adult supervision are not allowed in a zoo.";
    }
  }
}

