Ejemplo n.º 1
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (string.IsNullOrEmpty(Jmbag) || Jmbag.Length != 10 || !Jmbag.All(_ => char.IsDigit(_)))
     {
         yield return(new ValidationResult("JMBAG se mora sastojati od 10 znamenki", new[] { "Jmbag" }));
     }
 }
Ejemplo n.º 2
0
        public IDictionary <string, string> Validate()
        {
            var errors = new Dictionary <string, string>();

            if (string.IsNullOrEmpty(Jmbag) || Jmbag.Length != 10 || !Jmbag.All(_ => char.IsDigit(_)))
            {
                errors.Add(nameof(Jmbag), "Invalid JMBAG.");
            }

            if (string.IsNullOrWhiteSpace(Firstname))
            {
                errors.Add(nameof(Firstname), "Firstname is required.");
            }

            if (string.IsNullOrWhiteSpace(Lastname))
            {
                errors.Add(nameof(Lastname), "Lastname is required.");
            }

            return(errors);
        }