39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
namespace LaaProductionWeb.Services.Models
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
|
|
public class WildcardInputModel
|
|
{
|
|
private string token;
|
|
private IEnumerable<string> fields = Array.Empty<string>();
|
|
|
|
[Required]
|
|
[StringLength(50, MinimumLength = 1)]
|
|
[RegularExpression("^[0-9 a-z-A-Z]+$")]
|
|
public string Token
|
|
{
|
|
get => this.token;
|
|
set => this.token = value?.Replace(" ", "")?.Trim();
|
|
}
|
|
|
|
public string Fields
|
|
{
|
|
get => string.Join(",", this.fields);
|
|
set => this.fields = $"{value}".Split(new[] { ',' }, 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;
|
|
}
|
|
}
|
|
}
|