/// <summary> /// Validate the organization name /// </summary> /// <remarks> /// An organization name is valid if: /// <list type="bullet"> /// <item>All validation rules from <see cref="T:MARC.Everest.DataTypes.EN"/> are satisfied</item> /// <item>The <see cref="Use"/> property is not one of {Indigenous, Pseudonym, Anonymous, Artist, Religious, MaidenName }</item> /// <item>The <see cref="F:MARC.Everest.DataTypes.ENXP.Type"/> property of each <see cref="Part"/> is not in { Given, Family }</item> /// </list> /// </remarks> public override bool Validate() { bool isValid = base.Validate(); List <EntityNamePartType> disallowedPartTypes = new List <EntityNamePartType>() { EntityNamePartType.Given, EntityNamePartType.Family }; List <EntityNameUse?> disallowedUses = new List <EntityNameUse?>() { EntityNameUse.Indigenous, EntityNameUse.Pseudonym, EntityNameUse.Anonymous, EntityNameUse.Artist, EntityNameUse.Religious, EntityNameUse.MaidenName }; //object obj = disallowedQualifiers.Find(o => Use.Find(u => u.Code.Equals(o)) != null); if (Use != null) { isValid &= !disallowedUses.Exists(o => Use.Find(u => u.Code.Equals(o)) != null); } // Validate parts foreach (var part in Part) { isValid &= !disallowedPartTypes.Contains(part.Type.HasValue ? part.Type.Value : EntityNamePartType.Title); } return(isValid); }
/// <summary> /// Extended validation with reported problems /// </summary> /// <returns></returns> public override IEnumerable <Connectors.IResultDetail> ValidateEx() { var retVal = base.ValidateEx() as List <IResultDetail>; List <EntityNamePartType> disallowedPartTypes = new List <EntityNamePartType>() { EntityNamePartType.Given, EntityNamePartType.Family }; List <EntityNameUse?> disallowedUses = new List <EntityNameUse?>() { EntityNameUse.Indigenous, EntityNameUse.Pseudonym, EntityNameUse.Anonymous, EntityNameUse.Artist, EntityNameUse.Religious, EntityNameUse.MaidenName }; //object obj = disallowedQualifiers.Find(o => Use.Find(u => u.Code.Equals(o)) != null); if (Use != null && disallowedUses.Exists(o => Use.Find(u => u.Code.Equals(o)) != null)) { retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "ON", String.Format(EverestFrameworkContext.CurrentCulture, ValidationMessages.MSG_INVALID_VALUE, this.Use, "Use"))); } // Validate parts foreach (var part in Part) { if (disallowedPartTypes.Contains(part.Type.HasValue ? part.Type.Value : EntityNamePartType.Title)) { retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "ON", String.Format(EverestFrameworkContext.CurrentCulture, ValidationMessages.MSG_INVALID_VALUE, part.Type, "Part.Type"))); } } return(retVal); }