Пример #1
0
        public static IRuleBuilderOptions <TIn, string> FollowSchema <TIn>(
            this IRuleBuilder <TIn, string> builder,
            EntitySchema schema, Type entityType, string propName)
        {
            var prop = schema.GetString(entityType, propName);

            if (prop == null)
            {
                throw new KeyNotFoundException();
            }

            if (prop.IsUnboundLength)
            {
                return(builder.MaximumLength(int.MaxValue));
            }

            if (prop.IsFixLength)
            {
                return(builder.Length(prop.StringLength.Value));
            }

            return(builder.MaximumLength(prop.StringLength.Value));
        }