fix editing channel number (#59)
This commit is contained in:
@@ -74,7 +74,7 @@ namespace ErsatzTV.Application.Channels.Commands
|
|||||||
_ => BaseError.New("Channel number must be unique"),
|
_ => BaseError.New("Channel number must be unique"),
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
if (Regex.IsMatch(createChannel.Number, @"^[0-9]+(\.[0-9])?$"))
|
if (Regex.IsMatch(createChannel.Number, Channel.NumberValidator))
|
||||||
{
|
{
|
||||||
return createChannel.Number;
|
return createChannel.Number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace ErsatzTV.Application.Channels.Commands
|
|||||||
int matchId = match.Map(c => c.Id).IfNone(updateChannel.ChannelId);
|
int matchId = match.Map(c => c.Id).IfNone(updateChannel.ChannelId);
|
||||||
if (matchId == updateChannel.ChannelId)
|
if (matchId == updateChannel.ChannelId)
|
||||||
{
|
{
|
||||||
if (Regex.IsMatch(updateChannel.Number, @"^[0-9](\.[0-9])?$"))
|
if (Regex.IsMatch(updateChannel.Number, Channel.NumberValidator))
|
||||||
{
|
{
|
||||||
return updateChannel.Number;
|
return updateChannel.Number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ namespace ErsatzTV.Core.Domain
|
|||||||
{
|
{
|
||||||
public class Channel
|
public class Channel
|
||||||
{
|
{
|
||||||
|
public static string NumberValidator = @"^[0-9]+(\.[0-9])?$";
|
||||||
|
|
||||||
public Channel(Guid uniqueId) => UniqueId = uniqueId;
|
public Channel(Guid uniqueId) => UniqueId = uniqueId;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public Guid UniqueId { get; init; }
|
public Guid UniqueId { get; init; }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using ErsatzTV.ViewModels;
|
using ErsatzTV.Core.Domain;
|
||||||
|
using ErsatzTV.ViewModels;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
namespace ErsatzTV.Validators
|
namespace ErsatzTV.Validators
|
||||||
@@ -7,7 +8,7 @@ namespace ErsatzTV.Validators
|
|||||||
{
|
{
|
||||||
public ChannelEditViewModelValidator()
|
public ChannelEditViewModelValidator()
|
||||||
{
|
{
|
||||||
RuleFor(x => x.Number).Matches(@"^[0-9]+(\.[0-9])?$")
|
RuleFor(x => x.Number).Matches(Channel.NumberValidator)
|
||||||
.WithMessage("Invalid channel number; one decimal is allowed for subchannels");
|
.WithMessage("Invalid channel number; one decimal is allowed for subchannels");
|
||||||
|
|
||||||
RuleFor(x => x.Name).NotEmpty();
|
RuleFor(x => x.Name).NotEmpty();
|
||||||
|
|||||||
Reference in New Issue
Block a user