wiki:Doc/panc/tips

Version 2 (modified by /O=GRID-FR/C=FR/O=CNRS/OU=LAL/CN=Charles Loomis, 17 years ago) (diff)

--

Record Validation

type structure_enclosure = {
  'type' : string with match(self, 'blade|dumb|hypervisor')
  'children' : string[1..] with is_profile_list(self)
  'maxchildren' ? long(1..)
} with {
  if (exists(self['maxchildren'])) {
    self['maxchildren'] >= length(self['children']);
  } else {
    true;
  };
};

For the older compiler (v6) you must define an intermediate type as a 'with' clause on a record definition is not valid in the older compiler.

That is,

type structure_enclosure = {
  'type' : string with match(self, 'blade|dumb|hypervisor')
  'children' : string[1..] with is_profile_list(self)
  'maxchildren' ? long(1..)
} with {
  if (exists(self['maxchildren'])) {
    self['maxchildren'] >= length(self['children']);
  } else {
    true;
  };
};

type validated_structure_enclosure =
  structure_enclosure with {
    if (exists(self['maxchildren'])) {
      self['maxchildren'] >= length(self['children']);
    } else {
      true;
    };
  };