public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (string.IsNullOrEmpty(Code)) { yield return(new ValidationResult("Kode harus diisi", new List <string> { "Code" })); } else if (!long.TryParse(Code, out long code)) { yield return(new ValidationResult("Kode harus berupa angka", new List <string> { "Code" })); } if (string.IsNullOrEmpty(Name)) { yield return(new ValidationResult("Nama Barang harus diisi", new List <string> { "Name" })); } if (UOMId.GetValueOrDefault() <= 0) { yield return(new ValidationResult("Satuan harus diisi", new List <string> { "UOM" })); } if (CategoryId.GetValueOrDefault() <= 0) { yield return(new ValidationResult("Kategori Barang harus diisi", new List <string> { "Category" })); } }