private bool ValidateValue(MobeelizerFieldAccessor field, double doubleValue, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { bool includeMaxValue = GetIncludeMaxValue(options); bool includeMinValue = GetIncludeMinValue(options); Double minValue = Double.Parse(GetMinValue(options)); Double maxValue = Double.Parse(GetMaxValue(options)); if (includeMaxValue && doubleValue > maxValue) { errors.AddFieldMustBeLessThanOrEqualTo(field.Name, maxValue); return(false); } if (!includeMaxValue && doubleValue >= Double.MaxValue) { errors.AddFieldMustBeLessThan(field.Name, maxValue); return(false); } if (includeMinValue && doubleValue < minValue) { errors.AddFieldMustBeGreaterThanOrEqual(field.Name, minValue); return(false); } if (!includeMinValue && doubleValue <= Double.MinValue) { errors.AddFieldMustBeGreaterThan(field.Name, minValue); return(false); } return(true); }
private bool ValidateValue(MobeelizerFieldAccessor field, string value, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { int maxLength = GetMaxLength(options); if (((String)value).Length > maxLength) { errors.AddFieldIsTooLong(field.Name, maxLength); return(false); } return(true); }
protected override void ValidateValue(object value, MobeelizerFieldAccessor field, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { String stringValue = (String)value; if (!errors.IsValid) { return; } if (!((MobeelizerDatabase)Mobeelizer.GetDatabase()).Exists(options["model"], stringValue)) { errors.AddFieldMissingReferenceError(field.Name, stringValue); return; } }
public void Validate(IDictionary <String, object> values, MobeelizerFieldAccessor field, bool required, IDictionary <String, String> options, MobeelizerErrorsHolder errors) { Object value = values[field.Name]; if (value == null && required) { errors.AddFieldCanNotBeEmpty(field.Name); return; } if (value != null) { ValidateValue(value, field, options, errors); } }
private bool ValidateValue(MobeelizerFieldAccessor field, long longValue, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { int maxValue = GetMaxValue(options); int minValue = GetMinValue(options); if (longValue > maxValue) { errors.AddFieldMustBeLessThan(field.Name, (long)maxValue); return(false); } if (longValue < minValue) { errors.AddFieldMustBeGreaterThan(field.Name, (long)minValue); return(false); } return(true); }
protected override void SetNotNullValueFromMapToDatabase(IDictionary <string, object> values, string value, MobeelizerFieldAccessor field, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { Double doubleValue = Double.Parse(value); values.Add(field.Name, doubleValue); }
protected override void ValidateValue(object value, MobeelizerFieldAccessor field, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { ValidateValue(field, (Double)value, options, errors); }
protected override void SetNullValueFromMapToDatabase(IDictionary <string, object> values, MobeelizerFieldAccessor field, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { values.Add(field.Name, null); }
protected override void SetNotNullValueFromMapToDatabase(IDictionary <string, object> values, string value, MobeelizerFieldAccessor field, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { DateTime date = new DateTime(TimeSpan.FromMilliseconds(Int64.Parse(value)).Ticks + new DateTime(1970, 1, 1, 2, 0, 0, DateTimeKind.Utc).Ticks); values.Add(field.Name, date); }
internal static void Validate(this MobeelizerFieldType fieldType, IDictionary <String, object> values, MobeelizerFieldAccessor field, bool required, IDictionary <String, String> options, MobeelizerErrorsHolder errors) { typesMap[fieldType].Validate(values, field, required, options, errors); }
internal static void SetValueFromMapToDatabase(this MobeelizerFieldType fieldType, IDictionary <String, object> values, IDictionary <String, String> map, MobeelizerFieldAccessor field, bool required, IDictionary <String, String> options, MobeelizerErrorsHolder errors) { typesMap[fieldType].SetValueFromMapToDatabase(values, map, field, required, options, errors); }
protected virtual void ValidateValue(object value, MobeelizerFieldAccessor field, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { }
protected virtual void SetNullValueFromMapToDatabase(IDictionary <string, object> values, MobeelizerFieldAccessor field, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { }
internal void SetValueFromMapToDatabase(IDictionary <string, object> values, IDictionary <string, string> map, MobeelizerFieldAccessor field, bool required, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { String value = null; if (map.ContainsKey(GetFieldName(field.Name))) { value = map[GetFieldName(field.Name)]; } else if (map.ContainsKey(field.Name)) { value = map[field.Name]; } if (value == null && required) { errors.AddFieldCanNotBeEmpty(field.Name); return; } if (value == null) { SetNullValueFromMapToDatabase(values, field, options, errors); } else { SetNotNullValueFromMapToDatabase(values, value, field, options, errors); } }