public override object Format(object value, string name, IResolveManager resolveManager)
        {
            if (resolveManager != null)
            {
                textManager = resolveManager.Resolve <ITextManager>();
            }
            else
            {
                throw new PtvArgumentException("Resolve manager cannot be null and has to be provided.");
            }

            if (value == null)
            {
                return(null);
            }

            var valueToValidate = value as string;

            if (valueToValidate == null)
            {
                throw new PtvArgumentException($"Expected value is string! Value {value} of type {name} is not valid.");
            }

            var pureText = textManager.ConvertToPureText(valueToValidate);

            if (pureText.Length > maxLength)
            {
                throw new ArgumentOutOfRangeException(name, $"Expected length of '{name}' value is exceeded {maxLength} characters! '{name}' length {pureText.Length} is not valid.");
            }

            return(value);
        }
        private string CheckGeneralDescription(string gdDescription, ITextManager textManager)
        {
            var test1 = !string.IsNullOrWhiteSpace(gdDescription);
            var test2 = !string.IsNullOrWhiteSpace(textManager.ConvertToPureText(gdDescription));

            return(!string.IsNullOrWhiteSpace(gdDescription) && !string.IsNullOrWhiteSpace(textManager.ConvertToPureText(gdDescription))
                ? gdDescription
                : null);
        }
Beispiel #3
0
        protected bool NotEmptyTextEditorString <TOutProperty>(string key, Expression <Func <T, TOutProperty> > property)
        {
            var val   = property.Compile()(entity);
            var value = val as string;

            if (!string.IsNullOrEmpty(textManager.ConvertToPureText(value)))
            {
                return(false);
            }

            if (key != null)
            {
                AddValidationMessageToDictionary(key);
            }

            return(true);
        }