Пример #1
0
        public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context)
        {
            HtmlFieldOptions fieldOptions = (HtmlFieldOptions)options;

            if (fieldOptions.IsRequired && HasValue == false)
            {
                context.AddRequireValidation(fieldName);
            }
        }
Пример #2
0
        public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context)
        {
            ReferenceFieldOptions fieldOptions = (ReferenceFieldOptions)options;

            if (fieldOptions.IsRequired && ContentItem == null)
            {
                context.AddRequireValidation(fieldName);
            }
        }
Пример #3
0
        public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context)
        {
            AssetFieldOptions fieldOptions = (AssetFieldOptions)options;

            if (fieldOptions.IsRequired && Asset == null)
            {
                context.AddRequireValidation(fieldName);
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        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);
                }
            }
        }
Пример #6
0
        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);
                }
            }
        }
Пример #7
0
 public ContentSchemaField(string fieldType, ContentFieldOptions options)
 {
     FieldType = fieldType;
     Options   = options;
 }
Пример #8
0
 public virtual void Validate(string fieldName, ContentFieldOptions options, ValidationContext context)
 {
 }
Пример #9
0
        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);
        }