42 lines
1005 B
C#
42 lines
1005 B
C#
using System;
|
|
using FluentValidation;
|
|
using OnlineAssessment.Domain.ViewModels;
|
|
|
|
namespace OnlineAssessment.Validators
|
|
{
|
|
public class UserAddModelValidator : AbstractValidator<UserAddModel>
|
|
{
|
|
public UserAddModelValidator()
|
|
{
|
|
RuleFor(u => u.InstituteId)
|
|
.NotEmpty()
|
|
.NotNull()
|
|
.GreaterThan(0);
|
|
|
|
RuleFor(u => u.RoleId)
|
|
.NotEmpty()
|
|
.NotNull()
|
|
.GreaterThan(0);
|
|
|
|
RuleFor(u => u.LanguageId)
|
|
.NotEmpty()
|
|
.NotNull()
|
|
.GreaterThan(0);
|
|
|
|
RuleFor(u => u.FirstName)
|
|
.NotEmpty()
|
|
.NotNull()
|
|
.MaximumLength(50);
|
|
|
|
RuleFor(u => u.LastName).Length(0, 50);
|
|
|
|
RuleFor(u => u.MobileNo).Length(0, 10);
|
|
|
|
RuleFor(u => u.EmailId).EmailAddress();
|
|
|
|
RuleFor(u => u.RegistrationDatetime).LessThan(DateTime.Now);
|
|
|
|
}
|
|
}
|
|
}
|