Got the sliders extracted to their own page
This commit is contained in:
@@ -3,22 +3,20 @@
|
||||
using OpenArchival.DataAccess;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public class ArtifactEntryValidationModel
|
||||
public class ArtifactEntryValidationModel:IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Used when translating between the validation model and the database model
|
||||
/// </summary>
|
||||
public int? Id { get; set; }
|
||||
|
||||
[Required(AllowEmptyStrings = false, ErrorMessage = "An artifact numbering must be supplied")]
|
||||
public string? ArtifactNumber { get; set; }
|
||||
public string ArtifactNumber { get; set; }
|
||||
|
||||
[Required(AllowEmptyStrings = false, ErrorMessage = "A title must be provided")]
|
||||
public string? Title { get; set; }
|
||||
public string Title { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public string? Type { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
||||
public string? StorageLocation { get; set; }
|
||||
|
||||
@@ -94,4 +92,19 @@ public class ArtifactEntryValidationModel
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Title))
|
||||
yield return new ValidationResult("An artifact title must be provided.", [nameof(Title)]);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ArtifactNumber))
|
||||
yield return new ValidationResult("An artifact numbering must be supplied.", [nameof(ArtifactNumber)]);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Type))
|
||||
yield return new ValidationResult("An artifact type must be provided.", [nameof(Type)]);
|
||||
|
||||
if (string.IsNullOrEmpty(StorageLocation))
|
||||
yield return new ValidationResult("An artifact storage location must be provided.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,10 @@ public class ArtifactGroupingValidationModel : IValidatableObject
|
||||
/// </summary>
|
||||
public int? Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A grouping title is required.")]
|
||||
public string? Title { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A grouping description is required.")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A type is required.")]
|
||||
public string? Type { get; set; }
|
||||
|
||||
public ArchiveCategory? Category { get; set; }
|
||||
@@ -120,12 +117,21 @@ public class ArtifactGroupingValidationModel : IValidatableObject
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Title))
|
||||
yield return new ValidationResult("A grouping title must be provided.", [nameof(Title)]);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Description))
|
||||
yield return new ValidationResult("A grouping description must be provided.", [nameof(Description)]);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Type))
|
||||
yield return new ValidationResult("A grouping type must be provided.", [nameof(Type)]);
|
||||
|
||||
foreach (var entry in ArtifactEntries)
|
||||
{
|
||||
var context = new ValidationContext(entry);
|
||||
var validationResult = new List<ValidationResult>();
|
||||
|
||||
bool valid = Validator.TryValidateObject(entry, context, validationResult);
|
||||
bool valid = Validator.TryValidateObject(entry, context, validationResult, validateAllProperties:true);
|
||||
foreach (var result in validationResult)
|
||||
{
|
||||
yield return result;
|
||||
|
||||
Reference in New Issue
Block a user