Beispiel #1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            // Sql injection validation on text strings. just matching to keywords in sql to block unwanted injections.

            if (Country.Contains("Delete") || Country.Contains("Alter") || Name.Contains("Delete") || Name.Contains("Alter") || Adress.Contains("Delete") || Adress.Contains("Alter"))
            {
                yield return(new ValidationResult(
                                 $"Any sql keywords are banned.",
                                 new[] { nameof(Country) }));
            }
        }