/// <summary> /// Initializes static members of the ODataPayloadElementConfigurationValidator type. /// </summary> static ODataPayloadElementConfigurationValidator() { AllValidators = new Validators(); AllValidators.Add(NonEntityCollectionValidator, ODataPayloadElementType.PrimitiveMultiValue, ODataPayloadElementType.ComplexMultiValue); AllValidators.Add(StreamPropertyValidator, ODataPayloadElementType.NamedStreamInstance); AllValidators.Add(AssociationLinkValidator, ODataPayloadElementType.NavigationPropertyInstance); AllValidators.Add(SpatialValueValidator, ODataPayloadElementType.PrimitiveValue); AllValidators.Add(ActionAndFunctionValidator, ODataPayloadElementType.EntityInstance); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (!IsValid) { return; } if (txtNumberOfGuests.Text.Length == 0) { txtNumberOfGuests.Text = "1"; } Booking booking = new Booking { ClientName = txtClientName.Text, NumberOfGuests = Convert.ToInt32(txtNumberOfGuests.Text), ArrivalDate = Convert.ToDateTime(txtArrivalDate.Text), EmailAddress = txtEmailAddress.Text }; try { BookingManager.PlaceBooking(booking); } catch (ValidationException ex) { Validators.Add(new ValidationError(ex.Message)); return; } divForm.Visible = false; divSuccess.Visible = true; }
public TConfig Between(TProperty from, TProperty to, bool isExclusive = true, string error = null) { if (error == null) { string exclusiveSetting = string.Empty; if (!isExclusive) { exclusiveSetting = " including the two endpoints"; } error = $"Must be between {from} and {to}{exclusiveSetting}"; } var validator = new Validator <TProperty>( new Func <TProperty, ValidationResult>( (prop) => { var result = false; if (isExclusive) { result = prop.CompareTo(from) > 0 && prop.CompareTo(to) < 0; } else { result = prop.CompareTo(from) >= 0 && prop.CompareTo(to) <= 0; } return(new ValidationResult(result, error)); })); Validators.Add(validator); return(this as TConfig); }
public override void BuildControl(Engine.Effects.VisualPropertyItem pi) { Name = pi.ActualPropertyName; PropertyName = pi.ActualPropertyName; LabelText = pi.DisplayName; DataType = pi.DataType; DefaultValue = pi.DefaultValue; if (pi.ValidatorType != Engine.Attributes.Meta.ValidatorTypes.Undefined) { switch (pi.ValidatorType) { case Engine.Attributes.Meta.ValidatorTypes.Int: Validators.Add(new Engine.Validators.IntValidator()); if (pi.RangeMinimumValue != null && pi.RangeMaximumValue != null) { Validators.Add(new Engine.Validators.RangeIntValidator(pi.RangeMinimumValue.Value, pi.RangeMaximumValue.Value)); } break; default: throw new Exception(String.Format("In TPropertyIntBox, the validator type '{0}' is not supported.", pi.ValidatorType)); } } }
protected void btnLogin_Click(object sender, EventArgs e) { string email = txtEmail.Text; string lozinka = txtLozinka.Text; Osoba osoba = new Osoba(); osoba.Email = email; osoba.Lozinka = lozinka; if (referada.ValidirajOsobu(osoba)) { Osoba trenutnaOsoba = new Osoba(); trenutnaOsoba = referada.DobaviOsobu(email); if (cbRememberMe.Checked) { HttpCookie kuki = new HttpCookie("osoba"); kuki.Expires = DateTime.Now.AddDays(1); kuki["email"] = email; kuki["lozinka"] = Server.UrlEncode(lozinka); Response.Cookies.Add(kuki); DodajOsobuUSession(trenutnaOsoba); Response.Redirect("PrikazOsoba.aspx"); } else { DodajOsobuUSession(trenutnaOsoba); Response.Redirect("PrikazOsoba.aspx"); } } else { ResetirajPolja(); CustomValidator cv = new CustomValidator(); if (Request.Cookies["mojJezik"] != null) { var kultura = Request.Cookies["mojJezik"].Value; if (kultura != "0") { if (kultura == "en") { cv.ErrorMessage = "Password is incorrect or the account does not exist!"; } else if (kultura == "hr") { cv.ErrorMessage = "Lozinka nije ispravna ili osoba ne postoji!"; } } } cv.IsValid = false; Validators.Add(cv); } }
public EmbeddedDocumentValidationBuilder <TDocument, TEmbeddedIn, TProperty> Uniqueness(SaveType on = SaveType.Any) { Validators.Add(new EmbeddedDocumentUniquenessValidator <TDocument, TEmbeddedIn, TProperty>(_propertyExpression) { On = on }); return(this); }
public NestedContentPropertyValueEditor(DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService) : base(attribute) { _propertyEditors = propertyEditors; _dataTypeService = dataTypeService; _nestedContentValues = new NestedContentValues(contentTypeService); Validators.Add(new NestedContentValidator(propertyEditors, dataTypeService, _nestedContentValues)); }
/// <summary> /// Constructor used to set validators instead of adding them later /// </summary> /// <param name="validators"></param> public PreValueField(params IPropertyValidator[] validators) : this() { foreach (var v in validators) { Validators.Add(v); } }
/// <summary> /// Creates a new editor with the specified view /// </summary> /// <param name="view"></param> /// <param name="validators">Allows adding custom validators during construction instead of specifying them later</param> public PropertyValueEditor(string view, params IPropertyValidator[] validators) : this() { View = view; foreach (var v in validators) { Validators.Add(v); } }
protected override void OnInit(EventArgs e) { if (DoRequestValidation) { Validators.Add(_requestValidator); } base.OnInit(e); }
public NestedContentPropertyValueEditor(DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILocalizedTextService textService, ILogger logger) : base(attribute) { _propertyEditors = propertyEditors; _dataTypeService = dataTypeService; _logger = logger; _nestedContentValues = new NestedContentValues(contentTypeService); Validators.Add(new NestedContentValidator(_nestedContentValues, propertyEditors, dataTypeService, textService)); }
public BlockEditorPropertyValueEditor(DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILocalizedTextService textService, ILogger logger) : base(attribute) { _propertyEditors = propertyEditors; _dataTypeService = dataTypeService; _logger = logger; _blockEditorValues = new BlockEditorValues(new BlockListEditorDataConverter(), contentTypeService, _logger); Validators.Add(new BlockEditorValidator(_blockEditorValues, propertyEditors, dataTypeService, textService, contentTypeService)); Validators.Add(new MinMaxValidator(_blockEditorValues, textService)); }
public PropertyValueEditorWrapper(PropertyValueEditor wrapped) { this.HideLabel = wrapped.HideLabel; this.View = wrapped.View; this.ValueType = wrapped.ValueType; foreach (var v in wrapped.Validators) { Validators.Add(v); } }
public TestValueEditor( ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer, IIOHelper ioHelper, DataEditorAttribute attribute) : base(localizedTextService, shortStringHelper, jsonSerializer, ioHelper, attribute) { Validators.Add(new NeverValidateValidator()); }
public static void AddOrUpdate(this Validators validators, Validator validator) { var existingValidator = validators.SingleOrDefault(x => x.Name == validator.Name); if (existingValidator != null) { validators.Remove(existingValidator); } validators.Add(validator); }
public CreateContactParams() { Email = new HashSet <Email>(); Phone = new HashSet <Phone>(); Address = new HashSet <Address>(); Website = new HashSet <Website>(); CustomFields = new Dictionary <string, string>(); Validators.Add(ValidateName); Validators.Add(ValidateCompany); }
public void UseAnnotations(IEnumerable <CustomAttributeData> customAttributes) { if (!Validators.Any(d => d is LengthValidator)) { CustomAttributeData attr = customAttributes.FirstOrDefault(d => d.AttributeType == typeof(StringLengthAttribute)); if (attr != null) { int len = (int)attr.ConstructorArguments.Select(d => d.Value).FirstOrDefault(); Validators.Add(new LengthValidator(len)); } } }
public UpdatePipelineItemParams( string pipelineItemId, string statusId, string?note = null, int?priority = null, Dictionary <string, string>?customFields = null) : base(statusId, note, priority, customFields) { PipelineItemId = pipelineItemId; Validators.Add(ValidatePipelineItemId); }
public SearchContactsParams(string searchTerms, int?numRows = null, string?sort = null, string?recordType = null) { SearchTerms = searchTerms; NumRows = numRows; Sort = sort; RecordType = recordType; Validators.Add(ValidateSearchTerms); }
public void SetNumericDefaults() { if (Validators.Any(d => d is NumericTextValidator || d is RestrictNumericValidator)) { if (!Validators.Any(d => d is RestrictNumericValidator)) { Validators.Add(new RestrictNumericValidator()); } if (!Validators.Any(d => d is LengthValidator)) { AddLength(15); } } }
public void AddValidator(string errorHeader, ValidationAction <T> validationAction) { if (errorHeader == null || validationAction == null) { throw new InvalidOperationException("Arguments is null", new ArgumentNullException($"{nameof(errorHeader)} or {nameof(validationAction)} is null")); } if (Validators.ContainsKey(errorHeader)) { return; } Validators.Add(errorHeader, validationAction); }
public ArgumentsBase() { Validators.Add(new ReleaseIdRequiredAndPositive()); Validators.Add(new SeriesIdRequired()); Validators.Add(new SourceIdRequiredAndPositive()); Validators.Add(new TagNamesRequired()); Validators.Add(new SearchTextRequired()); Validators.Add(new SeriesSearchTextRequired()); Validators.Add(new Limit10K()); Validators.Add(new Limit100K()); Validators.Add(new Limit()); Validators.Add(new Offset()); Validators.Add(new TagNamesAndExcludeTagsNames()); }
public ModifyPipelineBase( string statusId, string?note = null, int?priority = null, Dictionary <string, string>?customFields = null) { Note = note; StatusId = statusId; Priority = priority; CustomFields = customFields; Validators.Add(ValidateStatusId); Validators.Add(ValidatePriority); }
private void AddValidators(string controlId) { var value = Value as String; Validators.Clear(); //Add Validators if (Required) { var requiredValidator = new RequiredFieldValidator { ID = ID + "_Required", ErrorMessage = ResourceKey + RequiredMessageSuffix }; if (String.IsNullOrEmpty(value) && Page.IsPostBack) { requiredValidator.IsValid = false; IsValid = requiredValidator.IsValid; } Validators.Add(requiredValidator); } if (!String.IsNullOrEmpty(ValidationExpression)) { var regexValidator = new RegularExpressionValidator { ID = ID + "_RegEx", ErrorMessage = ResourceKey + ValidationMessageSuffix, ValidationExpression = ValidationExpression }; if (!String.IsNullOrEmpty(value)) { regexValidator.IsValid = Regex.IsMatch(value, ValidationExpression); IsValid = regexValidator.IsValid; } Validators.Add(regexValidator); } if (Validators.Count > 0) { foreach (BaseValidator validator in Validators) { validator.ControlToValidate = controlId; validator.Display = ValidatorDisplay.Dynamic; validator.ErrorMessage = LocalizeString(validator.ErrorMessage); validator.CssClass = "dnnFormMessage dnnFormError"; Controls.Add(validator); } } }
public DocumentValidationBuilder <TDocument, TProperty> Uniqueness(bool caseSensitive = true, Expression <Func <TDocument, object> >[] scope = null, SaveType on = SaveType.Any, bool allowNull = false) { Validators.Add(new DocumentUniquenessValidator <TDocument, TProperty>(_propertyExpression) { On = on, CaseSensitive = caseSensitive, Scope = scope, AllowNull = allowNull }); return(this); }
public virtual IValidationCollection AddDate(CalendarTypes type, DateRange range = null) { DateValidator v; if (range == null) { v = new DateValidator(RazorConfig.DateValidationPattern, type); } else { v = new DateValidator(RazorConfig.DateValidationPattern, range); } Validators.Add(v); return(this); }
public CreatePipelineParams( string contactId, string pipelineId, string statusId, string?note = null, int?priority = null, Dictionary <string, string>?customFields = null) : base(statusId, note, priority, customFields) { ContactId = contactId; PipelineId = pipelineId; Validators.Add(ValidateContactId); Validators.Add(ValidatePipelineId); }
public override IValidationCollection AddDate(CalendarTypes type, DateRange range = null) { AngularDateValidator v; if (range == null) { v = new AngularDateValidator(type); } else { v = new AngularDateValidator(range); } Validators.Add(v); return(this); }
public StringPropertyConfiguration <TOwner> MaxLength(int maxLength, string error = null) { if (error == null) { error = $"Must have a maximum of {maxLength} character(s)"; } var validator = new Validator <string>( new Func <string, ValidationResult>( (prop) => { return(new ValidationResult(prop != null && prop.Length <= maxLength, error)); })); Validators.Add(validator); return(this); }
public StringPropertyConfiguration <TOwner> NotNullOrWhitespace(string error = null) { if (error == null) { error = $"Must not be whitespace"; } var validator = new Validator <string>( new Func <string, ValidationResult>( (prop) => { return(new ValidationResult(!string.IsNullOrWhiteSpace(prop), error)); })); Validators.Add(validator); return(this); }