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

            if (fieldOptions.IsRequired && ContentItem == null)
            {
                context.AddRequireValidation(fieldName);
            }
        }
Esempio n. 2
0
        public override void Validate(string fieldName, ContentFieldOptions options, ValidationContext context)
        {
            HtmlFieldOptions fieldOptions = (HtmlFieldOptions)options;

            if (fieldOptions.IsRequired && HasValue == false)
            {
                context.AddRequireValidation(fieldName);
            }
        }
Esempio 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);
            }
        }
Esempio 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);
            }
        }
Esempio 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);
                }
            }
        }
Esempio 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);
                }
            }
        }