39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
namespace LaaProduction.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;
|
|
}
|
|
}
|
|
}
|