public override void Validating(FormValidatingEventContext context)
        {
            foreach (var element in context.Form.Elements)
            {
                var fileFieldElement = element as FileField;

                if (fileFieldElement == null)
                    continue;

                try
                {
                    var path = context.Values[fileFieldElement.Name];

                    if (string.IsNullOrWhiteSpace(path))
                        return;

                    var postedFileValue = context.ValueProvider.GetValue(fileFieldElement.Name);

                    if (postedFileValue == null)
                        return;

                    var postedFile = ((System.Web.HttpPostedFileBase[])(postedFileValue.RawValue))[0];

                    using (var fileStream = File.Create(path))
                    {
                        postedFile.InputStream.Seek(0, SeekOrigin.Begin);
                        postedFile.InputStream.CopyTo(fileStream);
                    }
                }
                catch
                {
                    context.ModelState.AddModelError(fileFieldElement.Name, "Error Saving File");
                }
            }
        }
        public override void Validating(FormValidatingEventContext context) {
            var form = context.Form;
            var values = context.Values;
            var formValuesDictionary = values.ToTokenDictionary();

            var formTokenContext = new FormSubmissionTokenContext {
                Form = form,
                ModelState = context.ModelState,
                PostedValues = values
            };
            var tokensData = new Dictionary<string, object>(formValuesDictionary) {
                {"Updater", context.Updater},
                {"FormSubmission", formTokenContext},
            };

            _workflowManager.TriggerEvent(name: DynamicFormValidatingActivity.EventName, target: null, tokensContext: () => tokensData);
        }
        public override void Validating(FormValidatingEventContext context) {
            var form = context.Form;
            var values = context.Values;
            var formService = context.FormService;
            var formElements = formService.GetFormElements(form);
            var modelState = context.ModelState;

            // Get the validators for each element and validate its submitted values.
            foreach (var element in formElements) {
                var validators = formService.GetValidators(element);
                var attemptedValue = values[element.Name];

                foreach (var validator in validators) {
                    var validateContext = new ValidateInputContext {
                        ModelState = modelState,
                        AttemptedValue = attemptedValue,
                        FieldName = element.Name,
                        Values = values,
                        Updater = context.Updater
                    };
                    validator.Validate(element, validateContext);
                }
            }
        }
 public virtual void Validating(FormValidatingEventContext context) {}