34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
namespace LaaProductionWeb.API.Areas.Serach.Models
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
|
|
public class WildcardInputModel
|
|
{
|
|
private IEnumerable<string> fields = Array.Empty<string>();
|
|
|
|
[Required(ErrorMessageResourceType = typeof(ErrorMessages), ErrorMessageResourceName = nameof(ErrorMessages.Required))]
|
|
[StringLength(50, ErrorMessageResourceType = typeof(ErrorMessages), ErrorMessageResourceName = nameof(ErrorMessages.StringLength), MinimumLength = 1)]
|
|
[RegularExpression("^[0-9 a-z-A-Z]+$", ErrorMessageResourceType = typeof(ErrorMessages), ErrorMessageResourceName = nameof(ErrorMessages.RegularExpression))]
|
|
public string Token { get; set; }
|
|
|
|
public string Fields
|
|
{
|
|
get => string.Join(",", this.fields);
|
|
set => this.fields = $"{value}".Split(',', StringSplitOptions.RemoveEmptyEntries);
|
|
}
|
|
|
|
internal IEnumerable<string> GetRequiredFields(IEnumerable<string> allFields)
|
|
{
|
|
if (this.fields.Any())
|
|
{
|
|
return allFields.Where(x => this.fields.Contains(x, StringComparer.OrdinalIgnoreCase));
|
|
}
|
|
|
|
return allFields;
|
|
}
|
|
}
|
|
}
|