Skip to content

Commit 4f89eb7

Browse files
committed
Added ManufacturerDto validator.
1 parent 380caab commit 4f89eb7

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

Nop.Plugin.Api/DTOs/Manufacturers/ManufacturerDto.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
using Newtonsoft.Json;
1+
using FluentValidation.Attributes;
2+
using Newtonsoft.Json;
23
using Nop.Plugin.Api.DTOs.Base;
3-
using System;
4-
using System.Collections.Generic;
54
using Nop.Plugin.Api.DTOs.Images;
65
using Nop.Plugin.Api.DTOs.Languages;
6+
using Nop.Plugin.Api.Validators;
7+
using System;
8+
using System.Collections.Generic;
79

810
namespace Nop.Plugin.Api.DTOs.Manufacturers
911
{
1012
[JsonObject(Title = "manufacturer")]
11-
//[Validator(typeof(ManufacturerDtoValidator))]
13+
[Validator(typeof(ManufacturerDtoValidator))]
1214
public class ManufacturerDto : BaseDto
1315
{
1416
private ImageDto _imageDto;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Nop.Plugin.Api.Helpers;
3+
using System.Collections.Generic;
4+
using Nop.Plugin.Api.DTOs.Manufacturers;
5+
6+
namespace Nop.Plugin.Api.Validators
7+
{
8+
public class ManufacturerDtoValidator : BaseDtoValidator<ManufacturerDto>
9+
{
10+
11+
#region Constructors
12+
13+
public ManufacturerDtoValidator(IHttpContextAccessor httpContextAccessor, IJsonHelper jsonHelper, Dictionary<string, object> requestJsonDictionary) : base(httpContextAccessor, jsonHelper, requestJsonDictionary)
14+
{
15+
SetNameRule();
16+
}
17+
18+
#endregion
19+
20+
#region Private Methods
21+
22+
private void SetNameRule()
23+
{
24+
SetNotNullOrEmptyCreateOrUpdateRule(m => m.Name, "invalid name", "name");
25+
}
26+
27+
#endregion
28+
29+
}
30+
}

0 commit comments

Comments
 (0)