Ejemplo n.º 1
0
        public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context)
        {
            HtmlFieldOptions fieldOptions = (HtmlFieldOptions)options;

            if (fieldOptions.IsRequired && HasValue == false)
            {
                context.AddRequireValidation(fieldName);
            }
        }
Ejemplo n.º 2
0
        public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context)
        {
            ReferenceFieldOptions fieldOptions = (ReferenceFieldOptions)options;

            if (fieldOptions.IsRequired && ContentItem == null)
            {
                context.AddRequireValidation(fieldName);
            }
        }
Ejemplo n.º 3
0
        public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context)
        {
            AssetFieldOptions fieldOptions = (AssetFieldOptions)options;

            if (fieldOptions.IsRequired && Asset == null)
            {
                context.AddRequireValidation(fieldName);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 7
0
 public ContentSchemaField(string fieldType, ContentFieldOptions options)
 {
     FieldType = fieldType;
     Options   = options;
 }
Ejemplo n.º 8
0
 public virtual void Validate(string fieldName, ContentFieldOptions options, ValidationContext context)
 {
 }
Ejemplo n.º 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);
        }