Пример #1
0
        protected internal override bool ValidateSubmittedValue(IEnumerable <Field> allCollectedValues, IPublishedContent content)
        {
            if (base.ValidateSubmittedValue(allCollectedValues, content) == false)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(SubmittedValue))
            {
                return(true);
            }
            var emails = Multiple ? SubmittedValue.Split(',') : new[] { SubmittedValue };

            foreach (var email in emails)
            {
                try
                {
                    var address = new MailAddress(email);
                }
                catch
                {
                    return(false);
                }
            }
            return(true);
        }
 private string[] ExtractSubmittedValues()
 {
     return(SubmittedValue != null
                         ? IsMultiSelectEnabled
                                 ? SubmittedValue.Split(',')
                                 : new[] { SubmittedValue }
                         : new string[] {});
 }
Пример #3
0
 protected internal override void CollectSubmittedValue(Dictionary <string, string> allSubmittedValues, IPublishedContent content)
 {
     base.CollectSubmittedValue(allSubmittedValues, content);
     if (string.IsNullOrEmpty(SubmittedValue))
     {
         return;
     }
     if (SubmittedValue.StartsWith("[\"") && SubmittedValue.EndsWith("\"]"))
     {
         // #168: if the submitted value is a JSON string array, parse it to the expected CSV format
         SubmittedValue = string.Join(",", JsonConvert.DeserializeObject <string[]>(SubmittedValue));
     }
 }
Пример #4
0
        public IEnumerable <MailAddress> GetSubmittedMailAddresses()
        {
            var mailAddresses = new List <MailAddress>();

            foreach (var email in SubmittedValue.Split(','))
            {
                try
                {
                    mailAddresses.Add(new MailAddress(email));
                }
                catch
                {
                    // silently fail for invalid email addresses
                }
            }
            return(mailAddresses);
        }
Пример #5
0
        protected internal override bool ValidateSubmittedValue(IEnumerable <Field> allCollectedValues, IPublishedContent content)
        {
            if (base.ValidateSubmittedValue(allCollectedValues, content) == false)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(SubmittedValue))
            {
                // nothing selected => valid (mandatory validation is handled by base class)
                return(true);
            }

            var submittedFieldValues = SubmittedValue.Split(',');

            FieldValues.ToList().ForEach(f => f.Selected = submittedFieldValues.Contains(f.Value));

            // make sure all submitted values are actually defined as a field value (maybe some schmuck tampered with the options client side)
            if (submittedFieldValues.Any())
            {
                return(submittedFieldValues.All(v => FieldValues.Any(f => f.Value == v)));
            }

            return(true);
        }
Пример #6
0
 private string[] ExtractSubmittedValues()
 {
     return(SubmittedValue != null?SubmittedValue.Split(',') : new string[]
     {
     });
 }