protected override string ChildPropertyValidation(ModifiableEntity sender, System.Reflection.PropertyInfo pi) { if (sender is ChartScriptColumnEmbedded column && pi.Name == nameof(column.IsGroupKey)) { if (column.IsGroupKey) { if (!ChartUtils.Flag(ChartColumnType.Groupable, column.ColumnType)) { return("{0} can not be true for {1}".FormatWith(pi.NiceName(), column.ColumnType.NiceToString())); } } } if (sender is ChartScriptParameterEmbedded param && pi.Name == nameof(param.ColumnIndex)) { if (param.ColumnIndex == null && param.ShouldHaveColumnIndex()) { return(ValidationMessage._0IsNecessary.NiceToString(pi.NiceName())); } if (param.ColumnIndex.HasValue && !(0 <= param.ColumnIndex && param.ColumnIndex < this.Columns.Count)) { return(ValidationMessage._0HasToBeBetween1And2.NiceToString(pi.NiceName(), 0, this.Columns.Count)); } } return(base.ChildPropertyValidation(sender, pi)); }
protected override string PropertyValidation(System.Reflection.PropertyInfo pi) { if (pi.Name == nameof(GroupBy)) { if (GroupBy == GroupByChart.Always || GroupBy == GroupByChart.Optional) { if (!Columns.Any(a => a.IsGroupKey)) { return("{0} {1} requires some key columns".FormatWith(pi.NiceName(), GroupBy.NiceToString())); } } else { if (Columns.Any(a => a.IsGroupKey)) { return("{0} {1} should not have key".FormatWith(pi.NiceName(), GroupBy.NiceToString())); } } } if (pi.Name == nameof(Script)) { if (!Regex.IsMatch(Script, @"function\s+DrawChart\s*\(\s*chart\s*,\s*data\s*\)", RegexOptions.Singleline)) { return("{0} should be a definition of function DrawChart(chart, data)".FormatWith(pi.NiceName())); } } return(base.PropertyValidation(pi)); }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(RowId) && PropertyRoute != null) { if (RowId == null && PropertyRoute.Path.Contains("/")) return "{0} should be set for route {1}".FormatWith(pi.NiceName(), PropertyRoute); if (RowId != null && !PropertyRoute.Path.Contains("/")) return "{0} should be null for route {1}".FormatWith(pi.NiceName(), PropertyRoute); } return null; }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(Template) && Template == null && Active) return ValidationMessage._0IsNotSet.NiceToString(pi.NiceName()); return base.PropertyValidation(pi); }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(PostalCode)) { if (string.IsNullOrEmpty(PostalCode) && Country != "Ireland") return Signum.Entities.ValidationMessage._0IsNotSet.NiceToString().FormatWith(pi.NiceName()); } return null; }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Is(() => EachMinutes)) { if ((60 % EachMinutes) != 0) return SchedulerMessage._0IsNotMultiple1.NiceToString().FormatWith(pi.NiceName(), 60); } return base.PropertyValidation(pi); }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(Name) && Name != scriptParameter.Name) return ValidationMessage._0ShouldBe12.NiceToString(pi.NiceName(), ComparisonType.EqualTo.NiceToString(), scriptParameter.Name); if (pi.Name == nameof(Value)) return ScriptParameter.Valdidate(this.Value, this.ScriptParameter.GetToken(this.ParentChart)); return base.PropertyValidation(pi); }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(EachHours)) { if ((24 % EachHours) != 0) return SchedulerMessage._0IsNotMultiple1.NiceToString().FormatWith(pi.NiceName(), 24); } return base.PropertyValidation(pi); }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(Parameters) && Parameters != null && ChartScript != null) { try { EnumerableExtensions.JoinStrict( Parameters, ChartScript.Parameters, p => p.Name, ps => ps.Name, (p, ps) => new { p, ps }, pi.NiceName()); } catch (Exception e) { return e.Message; } } return base.PropertyValidation(pi); }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(Monday) && !(Monday || Tuesday || Wednesday || Thursday || Friday || Saturday || Sunday || Holiday)) return ValidationMessage._0IsNotSet.NiceToString(pi.NiceName()); return base.PropertyValidation(pi); }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(January) && !(0.To(12).Any(i => IsAllowed(i + 1)))) return ValidationMessage._0IsNotSet.NiceToString(pi.NiceName()); return base.PropertyValidation(pi); }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(EmbeddedInEntity)) { if (EmbeddedInEntity == null && EntityType != null) return ValidationMessage._0IsNecessary.NiceToString(pi.NiceName()); if (EmbeddedInEntity != null && EntityType == null) return ValidationMessage._0IsNotAllowed.NiceToString(pi.NiceName()); } return base.PropertyValidation(pi); }
protected override string PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(ElementsPerPage)) { if (ElementsPerPage != null && !ShouldHaveElements) return UserQueryMessage._0ShouldBeNullIf1Is2.NiceToString().FormatWith(pi.NiceName(), NicePropertyName(() => PaginationMode), PaginationMode?.Let(pm => pm.NiceToString()) ?? ""); if (ElementsPerPage == null && ShouldHaveElements) return UserQueryMessage._0ShouldBeSetIf1Is2.NiceToString().FormatWith(pi.NiceName(), NicePropertyName(() => PaginationMode), PaginationMode.NiceToString()); } if (pi.Name == nameof(Filters) && WithoutFilters && Filters.Any()) return UserQueryMessage._0ShouldBeEmptyIf1IsSet.NiceToString().FormatWith(pi.NiceName(), ReflectionTools.GetPropertyInfo(() => WithoutFilters).NiceName()); return base.PropertyValidation(pi); }