protected override bool RealValidate(HP.Rfg.Common.Questionnaire.IResponsePredefinedQuestionProvider elementToValidate, HP.Rfg.Common.Questionnaire.QuestionnaireDto questionnaire, ref bool isLengthCorrect, ref string incorrectLengthMsg) { bool retval = base.RealValidate(elementToValidate, questionnaire, ref isLengthCorrect, ref incorrectLengthMsg); if (retval) { List<ResponseDto> responses = elementToValidate.GetResponseDto(-1); retval = elementToValidate.IsValid = HP.Rfg.lib.utility.CheckEntryToRegex(constants.REGEX_EMAIL, ((QuestionResponseDto)responses[0]).ChoiceText); return retval; } return false; }
protected override bool RealValidate(HP.Rfg.Common.Questionnaire.IResponseElementProvider elementToValidate, HP.Rfg.Common.Questionnaire.QuestionnaireDto questionnaire) { bool retval = base.RealValidate(elementToValidate, questionnaire); if (retval) { List<ResponseDto> responses = elementToValidate.GetResponseDto(-1); bool valid = HP.Rfg.lib.utility.CheckEntryToRegex(constants.REGEX_EMAIL, ((QuestionResponseDto)responses[0]).ChoiceText); if (!valid) elementToValidate.SetValidationHints(new List<int>(new int[]{ PageElementWithErrorDto.InvalidEmail })); retval = elementToValidate.IsValid = valid; return retval; } return false; }
protected override bool RealValidate(HP.Rfg.Common.Questionnaire.IResponseElementProvider elementToValidate, HP.Rfg.Common.Questionnaire.QuestionnaireDto questionnaire) { bool retval = false; bool hasElement = false; bool hasMinLength = false; bool hasEmptyElements = false; bool isEqual = false; List<ResponseDto> responses = elementToValidate.GetResponseDto(-1); List<int> validationHints = new List<int>(); if (responses != null && responses.Count > 0) { PersonalResponseDto personal = ((PersonalResponseDto)responses[0]); if (personal != null) { hasElement = true; if (String.IsNullOrEmpty(personal.Pwd) && String.IsNullOrEmpty(personal.Pwdconfirm)) { hasEmptyElements = true; } else { if ((personal.Pwd.Length > MaxPwdLength) || (personal.Pwdconfirm.Length > MaxPwdLength)) { validationHints.Add(PageElementWithErrorDto.InvalidInputTooLong); } } if (!hasEmptyElements) { isEqual = string.Equals(personal.Pwd, personal.Pwdconfirm); if (!isEqual) validationHints.Add(PageElementWithErrorDto.PasswordsDontMatch); hasMinLength = (personal.Pwd.Length >= MinPwdLength) && (personal.Pwdconfirm.Length >= MinPwdLength); if (!hasMinLength) validationHints.Add(PageElementWithErrorDto.PasswordsToShort); } } else { throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissmatch, "Password validator does not accept a response of type \"" + responses[0].GetType().Name + "\""); } if (validationHints.Count == 0) { if (elementToValidate.PageElement.IsRequired) { if (!hasEmptyElements && hasElement && hasMinLength) { retval = isEqual; } } else { retval = (hasMinLength && isEqual) || hasEmptyElements; } } else { elementToValidate.SetValidationHints(validationHints); } } elementToValidate.IsValid = retval; return retval; }
protected override bool RealValidate(HP.Rfg.Common.Questionnaire.IResponseElementProvider elementToValidate, HP.Rfg.Common.Questionnaire.QuestionnaireDto questionnaire) { bool hasElement = false; bool hasEmptyElements = false; List<ResponseDto> responses = elementToValidate.GetResponseDto(-1); List<int> validationHints = null; if (responses != null && responses.Count > 0) { foreach (ResponseDto response in responses) { FileUploadResponseDto fileUploadResponse = response as FileUploadResponseDto; if (fileUploadResponse != null) { hasElement = true; if (String.IsNullOrEmpty(fileUploadResponse.FileName)) { hasEmptyElements = true; break; } else { string regex_pattern = utility.getParameter("regex_allowed_file_types"); if (!Regex.IsMatch(fileUploadResponse.FileName, regex_pattern, RegexOptions.Multiline | RegexOptions.IgnoreCase)) { validationHints = new List<int>(); validationHints.Add(PageElementWithErrorDto.InvalidFileType); } if (fileUploadResponse.FileBuffer.Length / (1024 * 1024) > 18 && validationHints == null) { validationHints = new List<int>(); validationHints.Add(PageElementWithErrorDto.InvalidFileType); } } } else { throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissmatch, "File Upload validator does not accept a response of type \"" + response.GetType().Name + "\""); } } } bool retval = false; if (validationHints == null) { if (elementToValidate.PageElement.IsRequired) { if (!hasEmptyElements && hasElement) { retval = true; } } else { retval = true; } } else { elementToValidate.SetValidationHints(validationHints); } elementToValidate.IsValid = retval; return retval; }
protected override bool RealValidate(HP.Rfg.Common.Questionnaire.IResponseElementProvider elementToValidate, HP.Rfg.Common.Questionnaire.QuestionnaireDto questionnaire) { bool hasAnswer = false; List<ResponseDto> responses = elementToValidate.GetResponseDto(-1); if (responses != null && responses.Count > 0) { PageElementChoiceDto subscribe = null; PageElementChoiceDto unsubscribe = null; foreach (PageElementChoiceDto dto in elementToValidate.Choices) { if (dto.LovKey == constants.COMM_SUBSCRIBE) { subscribe = dto; } else if (dto.LovKey == constants.COMM_UNSUBSCRIBE) { unsubscribe = dto; } } QuestionResponseDto subscribeResponse = responses.Find(delegate(ResponseDto cur) { QuestionResponseDto me = cur as QuestionResponseDto; return me != null && subscribe != null && me.ChoiceId == subscribe.ChoiceId; }) as QuestionResponseDto; QuestionResponseDto unsubscribeResponse = responses.Find(delegate(ResponseDto cur) { QuestionResponseDto me = cur as QuestionResponseDto; return me != null && unsubscribe != null && me.ChoiceId == unsubscribe.ChoiceId; }) as QuestionResponseDto; if ((subscribeResponse != null || unsubscribeResponse != null) && !(subscribeResponse != null && unsubscribeResponse != null)) { hasAnswer = true; SpecificCrmResponseDto crm = responses.Find(delegate(ResponseDto cur) { return cur is SpecificCrmResponseDto; }) as SpecificCrmResponseDto; if (crm != null) { if ((crm.ElementType == SpecificCrmResponseDto.ElementTypeRequestSubscribe || crm.ElementType == SpecificCrmResponseDto.ElementTypeRequestUnSubscribe) && crm.QuestionId == elementToValidate.PageElement.ElementId && crm.PageId == elementToValidate.PageElement.PageId && crm.CrmSubmit == questionnaire.SendToCrm && crm.CidSubmit == false && crm.QuestionnaireId == questionnaire.QuestionnaireId && !String.IsNullOrEmpty(crm.RespDesc)) { } else { throw new UserCausedException(Constants.UserCausedDataFormatIncorrect, "crm un- and subscribe requires a valid specific crm response"); } } else { throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissing, "crm un- and subscribe requires a specific crm response"); } } } bool retval = true; if (elementToValidate.PageElement.IsRequired) { if (!hasAnswer) { retval = false; } } elementToValidate.IsValid = retval; return retval; }
protected override bool RealValidate(HP.Rfg.Common.Questionnaire.IResponseElementProvider elementToValidate, HP.Rfg.Common.Questionnaire.QuestionnaireDto questionnaire) { bool hasMissingShippingData = false; List<ResponseDto> responses = elementToValidate.GetResponseDto(-1); List<int> validationHints = new List<int>(); PersonalDataSectionDto personalDataSectionDto = FormRegistry.PersonalDao.GetByPageId(elementToValidate.PageElement.PageId); if (responses != null && responses.Count > 0) { //check if any literature is selected List<ResponseDto> listOfQuestionResponses = responses.FindAll(r => r.GetType() == typeof(QuestionResponseDto)); if (listOfQuestionResponses != null && listOfQuestionResponses.Count > 0) { foreach (ResponseDto response in listOfQuestionResponses) { QuestionResponseDto questionResponse = response as QuestionResponseDto; if (questionResponse != null) { PageElementChoiceDto choice = elementToValidate.Choices.Find(delegate(PageElementChoiceDto cur) { return cur.ChoiceId == questionResponse.ChoiceId; }); if (choice == null) { throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissmatch, "Literature validator found response (" + questionResponse.ChoiceId + ") which does not have a corresponding choice"); } } else { throw new BugException("Literature validator does not accept a response of type \"" + response.GetType().Name + "\""); } } } ResponseDto shippingAddressResponse = responses.Find(pr => pr.GetType() == typeof(ShippingAddressResponseDto)); { if (shippingAddressResponse != null) { ShippingAddressResponseDto shAddress = shippingAddressResponse as ShippingAddressResponseDto; if (!shAddress.UseProfileFlag && personalDataSectionDto != null) { ValidateShippingAddress(shAddress, elementToValidate, validationHints, personalDataSectionDto); } } else hasMissingShippingData = true; } } bool retval = false; if (elementToValidate.PageElement.IsRequired) { if (!hasMissingShippingData) { if (validationHints.Count > 0) { elementToValidate.SetValidationHints(validationHints); } else { retval = true; } } } else { retval = true; } elementToValidate.IsValid = retval; return retval; }