Skip to content

Commit

Permalink
remove title validation
Browse files Browse the repository at this point in the history
  • Loading branch information
iammukeshm committed Jul 20, 2024
1 parent be82d06 commit 14dadd2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
7 changes: 1 addition & 6 deletions api/modules/Todo/Features/Create/v1/CreateTodoValidator.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using FluentValidation;
using FSH.WebApi.Todo.Persistence;
using Microsoft.EntityFrameworkCore;

namespace FSH.WebApi.Todo.Features.Create.v1;
public class CreateTodoValidator : AbstractValidator<CreateTodoCommand>
{
public CreateTodoValidator(TodoDbContext context)
{
RuleFor(p => p.Title)
.NotEmpty()
.MustAsync(async (title, token) => await context.Todos.AllAsync(a => a.Title != title, token).ConfigureAwait(false))
.WithMessage((_, name) => "todo item title '{PropertyValue}' already exists.");

RuleFor(p => p.Title).NotEmpty();
RuleFor(p => p.Note).NotEmpty();
}
}
7 changes: 1 addition & 6 deletions api/modules/Todo/Features/Update/v1/UpdateTodoValidator.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using FluentValidation;
using FSH.WebApi.Todo.Persistence;
using Microsoft.EntityFrameworkCore;

namespace FSH.WebApi.Todo.Features.Update.v1;
public class UpdateTodoValidator : AbstractValidator<UpdateTodoCommand>
{
public UpdateTodoValidator(TodoDbContext context)
{
RuleFor(p => p.Title)
.NotEmpty()
.MustAsync(async (title, token) => await context.Todos.AllAsync(a => a.Title != title, token).ConfigureAwait(false))
.WithMessage((_, name) => "todo item title '{PropertyValue}' already exists.");

RuleFor(p => p.Title).NotEmpty();
RuleFor(p => p.Note).NotEmpty();
}
}

0 comments on commit 14dadd2

Please sign in to comment.