Пример #1
0
        public static TContentSchema AddFloat <TContentSchema>(this TContentSchema schema, string name, Action <FloatFieldOptions>?configOptions = null)
            where TContentSchema : IContentSchema
        {
            FloatFieldOptions options = new FloatFieldOptions();

            configOptions?.Invoke(options);

            schema.AddField <FloatField>(name, options, null);

            return(schema);
        }
Пример #2
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);
                }
            }
        }