Пример #1
0
        public override IEnumerable <ValidationResult> Validate()
        {
            if (this.File == null || this.File?.Length == 0)
            {
                yield return(TfValidationResult.Compose("RequiredField", nameof(this.File)));
            }
            else
            {
                switch (this.FileType)
                {
                case Mvc.FileType.Image:
                    if (this.File.ContentType != "image/gif" &&
                        this.File.ContentType != "image/jpeg" &&
                        this.File.ContentType != "image/png" &&
                        this.File.ContentType != "image/svg+xml")
                    {
                        yield return(TfValidationResult.Compose("InvalidInput", nameof(this.File), nameof(this.File)));
                    }
                    break;

                case Mvc.FileType.CSV:
                    if (this.File.ContentType != "text/csv")
                    {
                        yield return(TfValidationResult.Compose("InvalidInput", nameof(this.File), nameof(this.File)));
                    }
                    break;
                }
            }
        }
Пример #2
0
        public override IEnumerable <ValidationResult> Validate()
        {
            yield return(TfValidationResult.FieldRequired(nameof(this.Key), this.Key));

            if (this.Accesses.Count == 0)
            {
                yield return(TfValidationResult.Compose("Unauthorized"));
            }
        }
Пример #3
0
 public override IEnumerable <ValidationResult> Validate()
 {
     if (this.Handling)
     {
         this.Accesses.Entity.key    = this.Key;
         this.Accesses.Entity.secret = this.Secret;
         if (this.Accesses.Count == 0)
         {
             yield return(TfValidationResult.Compose("Unauthorized"));
         }
     }
 }