internal static AuthorizeNet.APICore.validationModeEnum ToValidationMode(ValidationMode mode) { switch (mode) { case ValidationMode.None: return AuthorizeNet.APICore.validationModeEnum.none; case ValidationMode.TestMode: return AuthorizeNet.APICore.validationModeEnum.testMode; case ValidationMode.LiveMode: return AuthorizeNet.APICore.validationModeEnum.liveMode; default: return (AuthorizeNet.APICore.validationModeEnum)mode; } }
/// <summary>Returns an attribute of this XML element as a bitmap image. The attribute validation mode and default value can be specified.</summary> /// <param name="element">The XML element.</param> /// <param name="name">The attribute name.</param> /// <param name="defaultValue">The attribute's default value.</param> /// <param name="validationMode">The attribute validation mode.</param> public static BitmapSource GetImage(this XElement element, XName name, BitmapImage defaultValue, ValidationMode validationMode) { try { var attr = element.Attribute(name); if (attr == null) { if (validationMode == ValidationMode.Required) throw new MissingAttributeException(); return defaultValue; } var uri = new Uri((string)attr, UriKind.RelativeOrAbsolute); return ImageServices.LoadImage(uri); } catch (Exception e) { if (validationMode == ValidationMode.Tolerant) return defaultValue; throw _castException(e, element, name); } }
protected bool Equals(ValidationMode other) { return(string.Equals(_mode, other._mode)); }
/// <summary> /// This function validates the information on a profile - making sure what you have stored at AuthNET is valid. You can /// do this in two ways: in TestMode it will just run a validation to be sure all required fields are present and valid. If /// you specify "live" - a live authorization request will be performed. /// </summary> /// <param name="profileID">The profile ID.</param> /// <param name="paymentProfileID">The payment profile ID.</param> /// <param name="shippingAddressID">The shipping address ID.</param> /// <param name="mode">The mode.</param> /// <returns></returns> public string ValidateProfile(string profileID, string paymentProfileID, string shippingAddressID, ValidationMode mode) { var req = new validateCustomerPaymentProfileRequest(); req.customerProfileId = profileID; req.customerPaymentProfileId = paymentProfileID; if (!String.IsNullOrEmpty(shippingAddressID)) { req.customerShippingAddressId = shippingAddressID; } req.validationMode = Customer.ToValidationMode(mode); var response = (validateCustomerPaymentProfileResponse)_gateway.Send(req); return response.directResponse; }
private byte[] ValidateText(string text, ValidationMode mode, bool save_results, bool async) { var sr = new StringReader(text); var id = MakeId(save_results); var count = Encoding.UTF8.GetByteCount(text); byte[] bytes; bytes = ValidateHelper(mode, async, sr, id, count); return bytes; }
private byte[] AsyncValidate(long byte_count, TextReader tr, string id, ValidationMode mode) { var validator = new AsyncValidator(Validate); var result = validator.BeginInvoke(byte_count, tr, id, null, null); var seconds = 2; Thread.Sleep(seconds * 1000); if (result.IsCompleted) { var bytes = validator.EndInvoke(result); return bytes; } else { RedirectToProgressPage(mode, id, "0"); } return new byte[0]; }
public ResponseAlternateValidator(AccountSession accountSession, ValidationMode validationMode) : base(accountSession, validationMode) { }
/// <summary> /// Overload method ommitting shippingAddressID. /// </summary> /// <param name="profileID">The profile ID.</param> /// <param name="paymentProfileID">The payment profile ID.</param> /// <param name="mode">The mode.</param> /// <returns></returns> public string ValidateProfile(string profileID, string paymentProfileID, ValidationMode mode) { return(ValidateProfile(profileID, paymentProfileID, null, mode)); }
public static void ValidationMode(this IAccessorRulesExpression expression, ValidationMode mode) { expression.Add(mode); }
public static void MaxValue(this IAccessorRulesExpression expression, IComparable bounds, StringToken message, ValidationMode mode) { expression.Add(new MaxValueFieldRule(bounds, message) { Mode = mode }); }
public static void RangeLength(this IAccessorRulesExpression expression, int min, int max, StringToken message, ValidationMode mode) { expression.Add(new RangeLengthFieldRule(min, max, message) { Mode = mode }); }
public static void MinValue(this IAccessorRulesExpression expression, IComparable bounds, ValidationMode mode) { expression.Add(new MinValueFieldRule(bounds) { Mode = mode }); }
public static void MinimumLength(this IAccessorRulesExpression expression, int length, ValidationMode mode) { expression.Add(new MinimumLengthRule(length) { Mode = mode }); }
public static void Email(this IAccessorRulesExpression expression, ValidationMode mode) { expression.Add(new EmailFieldRule { Mode = mode }); }
public void setValidationMode(ValidationMode mode, double parameter) { this.checkPrepared(true); this.mode = mode; switch (this.mode) { case (ValidationMode.Holdout): this.kSplits = 2; this.holdoutSize = parameter; break; case (ValidationMode.KFold): this.kSplits = (int) parameter; this.currentHoldout = 0; break; default: throw new Exception("Invalid validation mode:" + mode); } }
/// <summary> /// Sets the value of the TextBoxRegex.ValidationMode XAML attached property for a target TextBox. /// </summary> /// <param name="textBox">TextBox to set the <see cref="ValidationMode"/> on.</param> /// <param name="value">TextBox <see cref="ValidationMode"/> value</param> public static void SetValidationMode(TextBox textBox, ValidationMode value) { textBox.SetValue(ValidationModeProperty, value); }
abstract protected void SendModeBytes(SerialPort port, ValidationMode validationMode);
public static void MaximumLength(this IAccessorRulesExpression expression, int length, StringToken message, ValidationMode mode) { expression.Add(new MaximumLengthRule(length, message) { Mode = mode}); }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Workers * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /// <summary> /// Executes a document/page command. /// </summary> /// <param name="command">Which command to execute.</param> /// <param name="mode">Which validation mode to use.</param> private static void CommandExecute(ModelCommand command, ValidationMode mode) { #region Validations if (command == null) { throw new ArgumentNullException(nameof(command)); } #endregion /* * #0. Settings! */ ModelExportSettings exportSettings = new ModelExportSettings(); exportSettings.Program = "VisioAddIn"; exportSettings.Mode = mode; if (string.IsNullOrEmpty(command.Document.Path) == false) { exportSettings.Path = System.IO.Path.GetDirectoryName(command.Document.Path); } /* * #1. Run the exporter */ ProgressForm pform = new ProgressForm(); pform.Command = command; pform.Settings = exportSettings; pform.ShowDialog(); /* * #2. Repaint everything to show that it's ok. * Paint all objects which have errors to red. * * TODO: This should probably be done in an undo unit, so that * the repainting of all of the shapes can be done atomically. */ foreach (ModelCommandPageResult pageResult in pform.CommandResult.Pages) { if (pageResult.Processed == false) { continue; } /* * Paint all black. */ Visio.IVPage page = command.Document.Pages[pageResult.Name]; if (page == null) { continue; } foreach (Visio.IVShape shape in page.Shapes) { Visio.VisDefaultColors orig = VU.ShapeColorGet(shape); if (orig != Visio.VisDefaultColors.visBlack) { VU.ShapeColorSet(shape, Visio.VisDefaultColors.visBlack); } } if (pageResult.Success == true) { continue; } /* * Paint red, only shapes with errors. */ foreach (ModelResultItem item in pageResult.Items) { if (item.ItemType != ModelResultItemType.Error) { continue; } if (item.VisioShapeId == null) { continue; } Visio.IVShape shape = page.Shapes[item.VisioShapeId]; if (shape == null) { continue; } VU.ShapeColorSet(shape, Visio.VisDefaultColors.visRed); } } /* * #3. */ ResultForm rform = new ResultForm(); rform.CommandResult = pform.CommandResult; rform.ShowDialog(); }
public static void GreaterOrEqualToZero(this IAccessorRulesExpression expression, ValidationMode mode) { expression.Add(new GreaterOrEqualToZeroRule { Mode = mode }); }
/// <inheritdoc /> public ContentLocationEventDataSerializer(ValidationMode validationMode) { _validationMode = validationMode; }
public static void GreaterOrEqualToZero(this IAccessorRulesExpression expression, StringToken message, ValidationMode mode) { expression.Add(new GreaterOrEqualToZeroRule(message) { Mode = mode }); }
/// <summary> /// Extension method to validate a class instance based on attribute validation declarations. /// Validation offenses are returned to let the client code know which validations failed. /// </summary> /// <remarks> /// The validations are performed on the class itself and all other related classes via aggregation and inheritance relationships. /// </remarks> /// <typeparam name="T">The type of object to validate.</typeparam> /// <param name="obj">The object to validate.</param> /// <param name="offenses">If obj is invalid, it contains the validation offenses, otherwise it is empty.</param> /// <param name="mode">The type of members to be validated, either properties or fields.</param> /// <param name="checkAll">True to gather all validation offenses. If false, the check stops at the first offense.</param> /// <returns>True if valid, false otherwise.</returns> public static bool IsValid <T>(this T obj, ref IList <ValidationOffense> offenses, ValidationMode mode = ValidationMode.Properties, bool checkAll = true) where T : class { if (offenses == null) { offenses = new List <ValidationOffense>(); } Type objectType = obj?.GetType(); // Consider either properties or fields because auto-implemented properties can have backing fields and there is no // safe way to tell them apart from regular ones without relying on assumptions. So, if a property's type is a class // where validation attributes are declared, checking both properties and fields of the enclosing type would result in // having the same validation run twice, once for the property and once for its backing field. foreach (var member in GetMembers(objectType, mode)) { object value = member.GetValue(obj); // Validate this member's attributes. if (!ValidateAttributes(member, objectType.Name, value, offenses, checkAll) && !checkAll) { return(false); } // If the member is a reference type, call this function recursively. if (member.MemberType.IsClass && member.MemberType != typeof(string)) { if (!value.IsValid(ref offenses, mode, checkAll) && !checkAll) { return(false); } } } return(offenses.Count == 0); }
public static void Required(this IAccessorRulesExpression expression, ValidationMode mode) { expression.Add(new RequiredFieldRule { Mode = mode }); }
private byte[] ValidateHelper(ValidationMode mode, bool async, TextReader tr, string id, long count) { byte[] bytes; if (async) bytes = AsyncValidate(count, tr, id, mode); else bytes = Validate(count, tr, id); return bytes; }
public static void Required(this IAccessorRulesExpression expression, StringToken message, ValidationMode mode) { expression.Add(new RequiredFieldRule(message) { Mode = mode }); }
/// <summary> /// Checks whether a graph meets its connection assertions. /// </summary> /// <param name="graph">The graph to validate.</param> /// <param name="mode">The validation mode to apply.</param> /// <param name="errors">If the graph is not valid, this refers to a List of ConnectionAssertionError objects, otherwise it is null.</param> /// <returns>True, if the graph is valid.</returns> public static bool Validate(IGraph graph, ValidationMode mode, out List<ConnectionAssertionError> errors) { bool result = true; Dictionary<IEdge, bool> checkedOutEdges = new Dictionary<IEdge, bool>(2 * graph.NumEdges); Dictionary<IEdge, bool> checkedInEdges = new Dictionary<IEdge, bool>(2 * graph.NumEdges); errors = new List<ConnectionAssertionError>(); int numConnectionAssertions = 0; foreach(ValidateInfo valInfo in graph.Model.ValidateInfo) { // Check outgoing count on nodes of source type foreach(INode node in graph.GetCompatibleNodes(valInfo.SourceType)) { result &= ValidateSource(node, valInfo, errors, checkedOutEdges, checkedInEdges); } // Check incoming count on nodes of target type foreach(INode node in graph.GetCompatibleNodes(valInfo.TargetType)) { result &= ValidateTarget(node, valInfo, errors, checkedOutEdges, checkedInEdges); } ++numConnectionAssertions; } if(mode == ValidationMode.StrictOnlySpecified) { Dictionary<EdgeType, bool> strictnessCheckedEdgeTypes = new Dictionary<EdgeType, bool>(2 * numConnectionAssertions); foreach(ValidateInfo valInfo in graph.Model.ValidateInfo) { if(strictnessCheckedEdgeTypes.ContainsKey(valInfo.EdgeType)) continue; foreach(IEdge edge in graph.GetExactEdges(valInfo.EdgeType)) { // Some edges with connection assertions specified are not covered; strict only specified validation prohibits that! if(!checkedOutEdges.ContainsKey(edge) || !checkedInEdges.ContainsKey(edge)) { errors.Add(new ConnectionAssertionError(CAEType.EdgeNotSpecified, edge, 0, null)); result = false; } } strictnessCheckedEdgeTypes.Add(valInfo.EdgeType, true); } } if(mode == ValidationMode.Strict && (graph.NumEdges != checkedOutEdges.Count || graph.NumEdges != checkedInEdges.Count)) { // Some edges are not covered; strict validation prohibits that! foreach(IEdge edge in graph.Edges) { if(!checkedOutEdges.ContainsKey(edge) || !checkedInEdges.ContainsKey(edge)) { errors.Add(new ConnectionAssertionError(CAEType.EdgeNotSpecified, edge, 0, null)); result = false; } } } if(result) errors = null; return result; }
public bool ValidateEmail(string strInputEmail, ValidationMode enumValidationMode = ValidationMode.Network) { string strAcceptableEmailAddressPattern = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; Regex regPatternEmail = new Regex(strAcceptableEmailAddressPattern); switch (enumValidationMode) { case ValidationMode.Syntax: try { return (regPatternEmail.IsMatch(strInputEmail)); } catch (Exception RegExPatternException) { GetLastError = string.Format("Could not match pattern because of the error {0} ", RegExPatternException.Message); return (false); } case ValidationMode.Network: if (ValidateEmail(strInputEmail, ValidationMode.Syntax)) { string strHostName = string.Empty; try { string[] arrHost = strInputEmail.Split('@'); strHostName = arrHost[1]; } catch (Exception HostMalformedException) { GetLastError = string.Format("Could not identify the target email server because of the error {0} ", HostMalformedException.Message); } try { Resolver objResolver = new Resolver(); Response objResponse = objResolver.Query(strHostName, QType.MX, QClass.IN); bool blnValidAddress = false; if (objResponse.RecordsMX.Length < 1) { return (false); } else { foreach (RecordMX recMx in objResponse.RecordsMX) { blnValidAddress = VerifySmtpResponse(recMx.EXCHANGE, strInputEmail); //if (blnValidAddress) break; } } return (blnValidAddress); } catch (Exception NetworkQueryException) { GetLastError = NetworkQueryException.Message; return (false); } } else { return (false); } default: return (false); } }
public IList <string> ValidateCourseRun(ICourseRun courseRun, ValidationMode validationMode) { var validationMessages = new List <string>(); // CourseName if (string.IsNullOrEmpty(courseRun.CourseName)) { validationMessages.Add("Course Name is required"); // "Enter Course Name" } else { if (!HasOnlyFollowingValidCharacters(courseRun.CourseName)) { validationMessages.Add("Course Name contains invalid character"); } if (courseRun.CourseName.Length > 255) { validationMessages.Add($"Course Name must be 255 characters or less"); } } // ProviderCourseID if (!string.IsNullOrEmpty(courseRun.ProviderCourseID)) { if (!HasOnlyFollowingValidCharacters(courseRun.ProviderCourseID)) { validationMessages.Add("ID contains invalid characters"); } if (courseRun.ProviderCourseID.Length > 255) { validationMessages.Add($"The maximum length of 'ID' is 255 characters"); } } // DeliveryMode switch (courseRun.DeliveryMode) { case DeliveryMode.ClassroomBased: // VenueId if (courseRun.VenueId == null || courseRun.VenueId == Guid.Empty) { validationMessages.Add($"Select a venue"); } // StudyMode if (courseRun.StudyMode.Equals(StudyMode.Undefined)) { validationMessages.Add($"Select Study Mode"); } // AttendancePattern if (courseRun.AttendancePattern.Equals(AttendancePattern.Undefined)) { validationMessages.Add($"Select Attendance Pattern"); } break; case DeliveryMode.Online: // No Specific Fields break; case DeliveryMode.WorkBased: // Regions if (courseRun.Regions == null || courseRun.Regions.Count().Equals(0)) { validationMessages.Add($"Select a region"); } break; case DeliveryMode.Undefined: // Question ??? default: validationMessages.Add($"DeliveryMode is Undefined. We are not checking the specific fields now. On editing you can select the appropriate Delivery Mode and the rest of the fields will be validated accordingly."); break; } // StartDate & FlexibleStartDate if (courseRun.StartDate != null) { courseRun.FlexibleStartDate = false; // COUR-746-StartDate switch (validationMode) { case ValidationMode.AddCourseRun: case ValidationMode.CopyCourseRun: if (courseRun.StartDate < DateTime.Now || courseRun.StartDate > DateTime.Now.AddYears(2)) { validationMessages.Add($"Start Date cannot be before Today's Date and must be less than or equal to 2 years from Today's Date"); } break; case ValidationMode.EditCourseYC: case ValidationMode.EditCourseMT: // It cannot be done easily as we need both value - the newly entered and the previous. Call to saved version or modification in the model break; case ValidationMode.EditCourseBU: // If the Provider does the editing on the same day of uploading it's fine. But from next day forward ????????? if (courseRun.StartDate < DateTime.Now || courseRun.StartDate > DateTime.Now.AddYears(2)) { validationMessages.Add($"Start Date cannot be before Today's Date and must be less than or equal to 2 years from Today's Date"); } break; case ValidationMode.BulkUploadCourse: if (courseRun.StartDate < DateTime.Now || courseRun.StartDate > DateTime.Now.AddYears(2)) { validationMessages.Add($"Start Date cannot be before Today's Date and must be less than or equal to 2 years from Today's Date"); } break; case ValidationMode.MigrateCourse: if (courseRun.StartDate > DateTime.Now.AddYears(2)) { validationMessages.Add($"Start Date must be less than or equal to 2 years from Today's Date"); } break; case ValidationMode.Undefined: default: validationMessages.Add($"Validation Mode was not defined."); break; } } if (courseRun.StartDate == null && courseRun.FlexibleStartDate == false) { validationMessages.Add($"Either 'Defined Start Date' or 'Flexible Start Date' has to be provided"); } // CourseURL if (!string.IsNullOrEmpty(courseRun.CourseURL)) { if (!IsValidUrl(courseRun.CourseURL)) { validationMessages.Add("The format of URL is incorrect"); } if (courseRun.CourseURL.Length > 255) { validationMessages.Add($"The maximum length of URL is 255 characters"); } } // Cost & CostDescription if (string.IsNullOrEmpty(courseRun.CostDescription) && courseRun.Cost.Equals(null)) { validationMessages.Add($"Enter cost or cost description"); } if (!string.IsNullOrEmpty(courseRun.CostDescription)) { if (!HasOnlyFollowingValidCharacters(courseRun.CostDescription)) { validationMessages.Add("Cost Description contains invalid characters"); } if (courseRun.CostDescription.Length > 255) { validationMessages.Add($"Cost description must be 255 characters or less"); } } if (!courseRun.Cost.Equals(null)) { if (!IsCorrectCostFormatting(courseRun.Cost.ToString())) { validationMessages.Add($"Enter the cost in pounds and pence"); } } // DurationUnit if (courseRun.DurationUnit.Equals(DurationUnit.Undefined)) { validationMessages.Add($"Select Duration Unit"); } // DurationValue if (courseRun.DurationValue.Equals(null)) { validationMessages.Add($"Enter Duration"); } else { if (!ValidDurationValue(courseRun.DurationValue?.ToString())) { validationMessages.Add("Duration must be numeric and maximum length is 3 digits"); } } return(validationMessages); }
public ResponseAgreementValidator(AccountSession accountSession, ValidationMode validationMode, ProviderResponseScheme response) : base(accountSession, validationMode) { #region Wake Date RuleFor(i => i.WakeDate) .HasAgreementDate(response, "WakeDate") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Wake Date must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Ceremony Date RuleFor(i => i.CeremonyDate) .HasAgreementDate(response, "CeremonyDate") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Funeral Date must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Internment Type RuleFor(i => i.InternmentType) .HasAgreement(response, "InternmentType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Internment must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Funeral Type RuleFor(i => i.FuneralType) .HasAgreement(response, "FuneralType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Funeral Style must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Wake Type RuleFor(i => i.WakeType) .HasAgreement(response, "WakeType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Wake Style must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Religion Type RuleFor(i => i.ReligionType) .HasAgreement(response, "ReligionType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Religion must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Expected Attendance Type RuleFor(i => i.ExpectedAttendanceType) .HasAgreement(response, "ExpectedAttendanceType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Expected attendance must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Service Preferences RuleFor(i => i.ServicePreferences) .HasAgreementText(response, "ServicePreferences") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Service Preferences must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Casket Material Type RuleFor(i => i.CasketMaterialType) .HasAgreement(response, "CasketMaterialType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Casket Material must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Casket Size Type RuleFor(i => i.CasketSizeType) .HasAgreement(response, "CasketSizeType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Casket Size must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Casket Color Type RuleFor(i => i.CasketColorType) .HasAgreement(response, "CasketColorType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Casket Color must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Casket Manufacturer Type RuleFor(i => i.CasketManufacturerType) .HasAgreement(response, "CasketManufacturerType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Casket Manufacturer must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Burial Container Type RuleFor(i => i.BurialContainerType) .HasAgreement(response, "BurialContainerType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Burial Container must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Transportation Of Family Type RuleFor(i => i.TransportationOfFamilyType) .HasAgreement(response, "TransportationOfFamilyType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Transportation of family must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Flower Spray Type RuleFor(i => i.FlowerSprayType) .HasAgreement(response, "FlowerSprayType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Flower Spray must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Primary Flower Type RuleFor(i => i.PrimaryFlowerType) .HasAgreement(response, "PrimaryFlowerType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Primary Flower must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Secondary Flower Type RuleFor(i => i.SecondaryFlowerType) .HasAgreement(response, "SecondaryFlowerType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Secondary Flower must be specified") .WithValidationContext(ValidationStatus.Required); #endregion #region Accent Flower Type RuleFor(i => i.AccentFlowerType) .HasAgreement(response, "AccentFlowerType") .When(i => (validationMode == ValidationMode.Pending)) .WithMessage("Accent Flower must be specified") .WithValidationContext(ValidationStatus.Required); #endregion }
/// <summary>Returns an attribute of this XML element as a bitmap image. The attribute validation mode can be specified.</summary> /// <param name="element">The XML element.</param> /// <param name="name">The attribute name.</param> /// <param name="validationMode">The attribute validation mode.</param> public static BitmapSource GetImage(this XElement element, XName name, ValidationMode validationMode) { return GetImage(element, name, null, validationMode); }
abstract public void SendMessage(SerialPort port, string msg, ValidationMode validationMode);
public Result <IList <CourseValidationResult> > CourseValidationMessages(IEnumerable <Course> courses, ValidationMode mode) { if (courses == null) { throw new ArgumentNullException(nameof(courses)); } try { IList <CourseValidationResult> results = new List <CourseValidationResult>(); foreach (Course c in courses) { CourseValidationResult cvr = new CourseValidationResult() { Course = c, RunValidationResults = new List <CourseRunValidationResult>() }; //Code to be refactored upon updated DQI stories if (mode != ValidationMode.DataQualityIndicator) { cvr.Issues = ValidateCourse(c).Select(x => x.Value).ToList(); } else { cvr.Issues = new List <string>(); } foreach (CourseRun r in c.CourseRuns) { cvr.RunValidationResults.Add(new CourseRunValidationResult() { Run = r, Issues = ValidateCourseRun(r, mode).Select(x => x.Value) }); } results.Add(cvr); } return(Result.Ok(results)); } catch (Exception ex) { _logger.LogError(ex, "PendingCourseValidationMessages error"); return(Result.Fail <IList <CourseValidationResult> >("Error compiling messages for items requiring attention on landing page")); } }
public ValidationResult Validate(AccountSession accountSession, ValidationMode validationMode) { return((new PaymentValidator(accountSession, validationMode)).Validate(this) as ValidationResult); }
public IList <KeyValuePair <string, string> > ValidateCourseRun(CourseRun courseRun, ValidationMode validationMode) { IList <KeyValuePair <string, string> > validationMessages = new List <KeyValuePair <string, string> >(); //Filtered down validation rules for DQI based on story //To be made more generic when we bring additional rules in if (validationMode == ValidationMode.DataQualityIndicator) { if (courseRun.StartDate < DateTime.Today) { validationMessages.Add(new KeyValuePair <string, string>("START_DATE", $"courses need their start date updating")); } return(validationMessages); } // CourseName if (string.IsNullOrEmpty(courseRun.CourseName)) { validationMessages.Add(new KeyValuePair <string, string>("COURSE_NAME", "Enter course name")); } else { if (!HasOnlyFollowingValidCharacters(courseRun.CourseName)) { validationMessages.Add(new KeyValuePair <string, string>("COURSE_NAME", "Course Name contains invalid character")); } if (courseRun.CourseName.Length > 255) { validationMessages.Add(new KeyValuePair <string, string>("COURSE_NAME", $"Course Name must be 255 characters or less")); } } // ProviderCourseID if (!string.IsNullOrEmpty(courseRun.ProviderCourseID)) { if (!HasOnlyFollowingValidCharacters(courseRun.ProviderCourseID)) { validationMessages.Add(new KeyValuePair <string, string>("ID", "ID contains invalid characters")); } if (courseRun.ProviderCourseID.Length > 255) { validationMessages.Add(new KeyValuePair <string, string>("ID", $"The maximum length of 'ID' is 255 characters")); } } // DeliveryMode switch (courseRun.DeliveryMode) { case DeliveryMode.ClassroomBased: // VenueId if (courseRun.VenueId == null || courseRun.VenueId == Guid.Empty) { validationMessages.Add(new KeyValuePair <string, string>("VENUE", $"Select venue")); } // StudyMode if (courseRun.StudyMode.Equals(StudyMode.Undefined)) { validationMessages.Add(new KeyValuePair <string, string>("STUDY_MODE", $"Select Study Mode")); } // AttendancePattern if (courseRun.AttendancePattern.Equals(AttendancePattern.Undefined)) { validationMessages.Add(new KeyValuePair <string, string>("ATTENDANCE_PATTERN", $"Select Attendance Mode")); } break; case DeliveryMode.Online: // No Specific Fields break; case DeliveryMode.WorkBased: //National if (courseRun.National == null) { validationMessages.Add(new KeyValuePair <string, string>("NATIONAL_DELIVERY", $"Choose if you can deliver this course anywhere in England")); } else if (courseRun.National == false) { // Regions if (courseRun.Regions == null || courseRun.Regions.Count().Equals(0)) { validationMessages.Add(new KeyValuePair <string, string>("REGION", $"Select at least one region or sub-region")); } } break; case DeliveryMode.Undefined: // Question ??? default: validationMessages.Add(new KeyValuePair <string, string>("DELIVERY_MODE", $"Select Delivery Mode")); break; } // StartDate & FlexibleStartDate if (courseRun.StartDate != null) { courseRun.FlexibleStartDate = false; // COUR-746-StartDate var currentDate = DateTime.UtcNow.Date; switch (validationMode) { case ValidationMode.AddCourseRun: case ValidationMode.CopyCourseRun: case ValidationMode.EditCourseBU: case ValidationMode.BulkUploadCourse: _logger.LogError("course date" + courseRun.StartDate.Value.Date + "utc Date " + currentDate); int result = DateTime.Compare(courseRun.StartDate.Value.Date, currentDate); if (result < 0) { _logger.LogWarning("*Simon* Date in the past"); } if (courseRun.StartDate < currentDate) { validationMessages.Add(new KeyValuePair <string, string>("START_DATE", $"Start Date cannot be earlier than today's date")); } if (courseRun.StartDate > currentDate.AddYears(2)) { validationMessages.Add(new KeyValuePair <string, string>("START_DATE", $"Start Date cannot be later than 2 years from today’s date")); } break; case ValidationMode.EditCourseYC: case ValidationMode.EditCourseMT: // It cannot be done easily as we need both value - the newly entered and the previous. Call to saved version or modification in the model break; case ValidationMode.MigrateCourse: if (courseRun.StartDate > currentDate.AddYears(2)) { validationMessages.Add(new KeyValuePair <string, string>("START_DATE", $"Start Date cannot be later than 2 years from today’s date")); } break; case ValidationMode.Undefined: default: validationMessages.Add(new KeyValuePair <string, string>("START_DATE", $"Validation Mode was not defined.")); break; } } if (courseRun.StartDate == null && courseRun.FlexibleStartDate == false) { validationMessages.Add(new KeyValuePair <string, string>("START_DATE+FLEXIBLE_START_DATE", $"Either 'Defined Start Date' or 'Flexible Start Date' has to be provided")); } // CourseURL if (!string.IsNullOrEmpty(courseRun.CourseURL)) { if (!IsValidUrl(courseRun.CourseURL)) { validationMessages.Add(new KeyValuePair <string, string>("URL", "The format of URL is incorrect")); } if (courseRun.CourseURL.Length > 255) { validationMessages.Add(new KeyValuePair <string, string>("URL", $"The maximum length of URL is 255 characters")); } } // Cost & CostDescription if (string.IsNullOrEmpty(courseRun.CostDescription) && courseRun.Cost.Equals(null)) { validationMessages.Add(new KeyValuePair <string, string>("COST", $"Enter cost or cost description")); } if (!string.IsNullOrEmpty(ReplaceSpecialCharacters(courseRun.CostDescription))) { if (!HasOnlyFollowingValidCharacters(ReplaceSpecialCharacters(courseRun.CostDescription))) { validationMessages.Add(new KeyValuePair <string, string>("COST_DESCRIPTION", "Cost Description contains invalid characters")); } if (courseRun.CostDescription.Length > 255) { validationMessages.Add(new KeyValuePair <string, string>("COST_DESCRIPTION", $"Cost description must be 255 characters or less")); } } if (!courseRun.Cost.Equals(null)) { if (!IsCorrectCostFormatting(courseRun.Cost.ToString())) { validationMessages.Add(new KeyValuePair <string, string>("COST", $"Enter the cost in pounds and pence")); } if (courseRun.Cost > decimal.Parse("999999.99")) { validationMessages.Add(new KeyValuePair <string, string>("COST", $"Maximum allowed cost value is 999,999.99")); } } // DurationValue and DurationUnit if (courseRun.DurationValue.Equals(null) || courseRun.DurationUnit.Equals(DurationUnit.Undefined)) { validationMessages.Add(new KeyValuePair <string, string>("DURATION", $"Enter duration")); } else { if (!ValidDurationValue(courseRun.DurationValue?.ToString())) { validationMessages.Add(new KeyValuePair <string, string>("DURATION", "Duration must be numeric and maximum length is 3 digits")); } } return(validationMessages); }
public async override Task <IEnumerable <ValidationResult> > ValidateWithDbConnectionAsync(DbContext unitOfWork, ValidationMode mode) { var errors = new List <ValidationResult>(); return(errors); }
public ValidationResult Validate(AccountSession accountSession, ValidationMode validationMode) { return((new AdministratorRegistrationFormValidator(accountSession, validationMode)).Validate(this) as ValidationResult); }
public ValidationResult Validate(AccountSession accountSession, ValidationMode validationMode) { return((new ConsumerRequestValidator(accountSession, validationMode)).Validate(this) as ValidationResult); }
internal NgClassErrorBinding(ValidationMode validationMode, AngularForm <TModel> form) { _validationMode = validationMode; _form = form; }
/// <summary> /// This function validates the information on a profile - making sure what you have stored at AuthNET is valid. You can /// do this in two ways: in TestMode it will just run a validation to be sure all required fields are present and valid. If /// you specify "live" - a live authorization request will be performed. /// </summary> /// <param name="profileID">The profile ID.</param> /// <param name="paymentProfileID">The payment profile ID.</param> /// <param name="shippingAddressID">The shipping address ID.</param> /// <param name="mode">The mode.</param> /// <returns></returns> public string ValidateProfile(string profileID, string paymentProfileID, string shippingAddressID, ValidationMode mode) { var req = new validateCustomerPaymentProfileRequest(); req.customerProfileId = profileID; req.customerPaymentProfileId = paymentProfileID; if (!String.IsNullOrEmpty(shippingAddressID)) { req.customerShippingAddressId = shippingAddressID; } req.validationMode = Customer.ToValidationMode(mode); var response = (validateCustomerPaymentProfileResponse)_gateway.Send(req); return(response.directResponse); }
private ValidationContext Clone(ImmutableQueue <string> path, bool isOptional, ValidationMode mode) { return(new ValidationContext( contentId, schemaId, checkContent, checkContentByIds, checkAsset, path, isOptional, mode)); }
public override async Task <IEnumerable <ValidationResult> > ValidateWithDbConnectionAsync(DbContext context, ValidationMode mode) { var errors = new List <ValidationResult>(); return(await Task.FromResult(errors)); }
public DataManagerValidator(ValidationMode mode) { this.mode = mode; }
/// <summary> /// Extension method to validate a class instance based on attribute validation declarations. /// </summary> /// <remarks> /// The validations are performed on the class itself and all other related classes via aggregation and inheritance relationships. /// </remarks> /// <typeparam name="T">The type of object to validate.</typeparam> /// <param name="obj">The object to validate.</param> /// <param name="mode">The type of members to be validated, either properties or fields.</param> /// <returns>True if valid, false otherwise.</returns> public static bool IsValid <T>(this T obj, ValidationMode mode = ValidationMode.Properties) where T : class { IList <ValidationOffense> offenses = null; return(obj.IsValid(ref offenses, mode, false)); }
public ResetTicketValidator(IResetTicketManager manager, ValidationMode mode) : base(manager, mode) { RuleFor(x => x.Username) .MustAsync(async(x, token) => await Task.FromResult(ServiceLocator.Current.Get <IUserManager>().GetByEmail(x)) != null); }
public JoyPage() { vmode = ValidationMode.None; password = string.Empty; IsAthenticated = false; }
/// <nodoc /> public ContentLocationEventDataSerializer(ValidationMode validationMode, bool synchronize = false) { _validationMode = validationMode; _synchronize = synchronize; }
private void RedirectToProgressPage(ValidationMode mode, string id, string progress) { var redirect_uri = string.Format(progress_fmt, mode, "", id, 0); Response.Redirect(redirect_uri); }
public ProviderProfileValidator(AccountSession accountSession, ValidationMode validationMode) : base(accountSession, validationMode) { #region Description RuleFor(i => i.Description) .NotEmpty() .When(i => (validationMode == ValidationMode.Update)) .WithMessage("Description must be specified") .WithValidationContext(ValidationStatus.Invalid) .Length(0, 3000) .When(i => (validationMode == ValidationMode.Update)) .WithMessage("Description must be 3000 characters or less") .WithValidationContext(ValidationStatus.Invalid); #endregion #region Website RuleFor(i => i.Website) .EnsureUrl() .WithMessage("Website URL invalid") .WithValidationContext(ValidationStatus.Invalid) .Length(0, 100) .WithMessage("Website URL must be 100 characters or less") .WithValidationContext(ValidationStatus.Invalid); #endregion #region Business Established RuleFor(i => i.BusinessEstablished) .NotEqual(BusinessEstablishedTypes.NA) .When(i => (validationMode == ValidationMode.Update)) .WithMessage("Business established length must be specified") .WithValidationContext(ValidationStatus.Invalid); #endregion #region FacilityAge RuleFor(i => i.FacilityAge) .NotEqual(FacilityAgeTypes.NA) .When(i => (validationMode == ValidationMode.Update)) .WithMessage("Facility age must be specified") .WithValidationContext(ValidationStatus.Invalid); #endregion #region Facility Style RuleFor(i => i.FacilityStyle) .NotEqual(FacilityStyleTypes.NA) .When(i => (validationMode == ValidationMode.Update)) .WithMessage("Facility style must be specified") .WithValidationContext(ValidationStatus.Invalid); #endregion #region Funeral Director Experience RuleFor(i => i.FuneralDirectorExperience) .NotEqual(FuneralDirectorExperienceTypes.NA) .When(i => (validationMode == ValidationMode.Update)) .WithMessage("Funeral directors' experience must be specified") .WithValidationContext(ValidationStatus.Invalid); #endregion #region Transportation Fleet Age RuleFor(i => i.TransportationFleetAge) .NotEqual(TransportationFleetAgeTypes.NA) .When(i => (validationMode == ValidationMode.Update)) .WithMessage("Transportation fleet age must be specified") .WithValidationContext(ValidationStatus.Invalid); #endregion }
private byte[] ValidateStream(Stream s, ValidationMode mode, bool save_results, bool async) { string id = MakeId(save_results); var sr = new StreamReader(s); var count = s.Length; byte[] bytes = ValidateHelper(mode, async, sr, id, count); return bytes; }
private ValidationContext Clone(ImmutableQueue <string> path, bool isOptional, ValidationMode mode) { return(new ValidationContext(AppId, SchemaId, Schema, ContentId, path, isOptional, mode)); }
public bool Validate(ValidationMode mode, out List<ConnectionAssertionError> errors) { return GraphValidator.Validate(this, mode, out errors); }
public StateMachineHostBuilder DisableVerboseValidation() { _validationMode = ValidationMode.Default; return(this); }
/// <summary> /// Overload method ommitting shippingAddressID. /// </summary> /// <param name="profileID">The profile ID.</param> /// <param name="paymentProfileID">The payment profile ID.</param> /// <param name="mode">The mode.</param> /// <returns></returns> public string ValidateProfile(string profileID, string paymentProfileID, ValidationMode mode) { return ValidateProfile(profileID, paymentProfileID, null, mode); }
/// <summary> /// Performs additional validation of pre-defined values for the IQVarEnumActivity. /// </summary> /// <param name="errors"></param> /// <param name="pValidationMode"></param> public override void ValidatePreselectedValues(IList<ValidationError> errors, ValidationMode pValidationMode) { if(PreselectedValues.Count == 0) { //Hack to clear the selected values if no pre-selected values exist. if (SetToNoneAction != null) SetToNoneAction(); else SetStateToNotSet(); } var groups = PreselectedValues.GroupBy(e => e.Value); if (groups.Any(group => group.Count() > 1)) errors.Add(new ValidationError(Strings.IQEnumVarActivity_DuplicateKey, false, "Config")); base.ValidatePreselectedValues(errors, pValidationMode); }
protected bool Equals(ValidationMode other) { return string.Equals(_mode, other._mode); }
protected ValidationModeAttribute(ValidationMode mode) { _mode = mode; }