public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context) { HtmlFieldOptions fieldOptions = (HtmlFieldOptions)options; if (fieldOptions.IsRequired && HasValue == false) { context.AddRequireValidation(fieldName); } }
public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context) { ReferenceFieldOptions fieldOptions = (ReferenceFieldOptions)options; if (fieldOptions.IsRequired && ContentItem == null) { context.AddRequireValidation(fieldName); } }
public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context) { AssetFieldOptions fieldOptions = (AssetFieldOptions)options; if (fieldOptions.IsRequired && Asset == null) { context.AddRequireValidation(fieldName); } }
public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context) { ArrayFieldOptions fieldOptions = (ArrayFieldOptions)options; if (fieldOptions.IsRequired && Items.Any() == false) { context.AddRequireValidation(fieldName); } if (Items.Count < fieldOptions.MinItems || Items.Count > fieldOptions.MaxItems) { context.AddRangeValidation(fieldName, fieldOptions.MinItems, fieldOptions.MaxItems); } }
public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context) { FloatFieldOptions fieldOptions = (FloatFieldOptions)options; if (fieldOptions != null) { if (fieldOptions.IsRequired && HasValue == false) { context.AddRequireValidation(fieldName); } if (Value < fieldOptions.MinValue || Value > fieldOptions.MaxValue) { context.AddRangeValidation(fieldName, fieldOptions.MinValue, fieldOptions.MaxValue); } } }
public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context) { StringFieldOptions fieldOptions = (StringFieldOptions)options; if (fieldOptions.IsRequired && HasValue == false) { context.AddRequireValidation(fieldName); } if (HasValue) { if (Value.Length < fieldOptions.MinLength) { context.AddMinimumValidation(fieldName, fieldOptions.MinLength); } else if (Value.Length > fieldOptions.MaxLength) { context.AddMaximumValidation(fieldName, fieldOptions.MaxLength); } } }
public ContentSchemaField(string fieldType, ContentFieldOptions options) { FieldType = fieldType; Options = options; }
public virtual void Validate(string fieldName, ContentFieldOptions options, ValidationContext context) { }
public static IContentSchema AddField(this IContentSchema schema, string name, Type fieldType, ContentFieldOptions options, int?sortkey = null) { schema.Fields.Add(name, new ContentSchemaField(ContentFieldManager.Default.GetContentFieldName(fieldType), options) { SortKey = sortkey ?? 0, Options = options }); return(schema); }