TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
darma teja
NA
496
336.4k
create custom validator-fluentvalidation
Oct 6 2017 9:39 AM
I would like to create fluentValidation cutomer validator, So that I can use this custom validator in coming projects.
My class is and xxxxxxxxx-want to get custom method after implementation of code (I tried but not giving +ve output-see my following code)
namespace
ratenamespace
{
public
class
ratecmd
{
[NoODataProcedureParameter]
public
int
? ProductId {
get
;
set
; }
[NoODataProcedureParameter]
public
int
? PlaceId {
get
;
set
; }
[NoODataProcedureParameter]
public
int
? Rate {
get
;
set
; }
}
public
class
ratecmdValidator : AbstractValidator
{
public
ratecmd()
{
RuleFor(x => x.Rate).
xxxxxxxxx
;
}}}
I have created seperate class for custom validator like this:
public
class
myValidator
: PropertyValidator
{
public
myValidator()
:
base
(
"{PropertyName} must be greater than zero and not null."
) { }
protected
override
bool
IsValid(PropertyValidatorContext context)
{
int
? rate = context.PropertyValue
as
int
?;
if
(rate !=
null
&& rate <= 0)
{
return
false
;
}
return
true
;
}
}
Reply
Answers (
1
)
In APP Purchases
C# Reference Error