public OverallValidationResult Validate(Email email) { return(_emailValidator.Validate(email).ApplyResultsTo(_emailValidatables)); }
public static ValidationResult ValidateFields <T>(this AbstractValidator <T> validation, T instance, params string[] fields) { var context = new ValidationContext <T>(instance, new PropertyChain(), new MemberNameValidatorSelector(fields)); return(validation.Validate(context)); }
protected bool Validate <T>(AbstractValidator <T> validator) where T : Command <RT> { var validationResult = validator.Validate((T)this); return(validationResult.IsValid); }
protected bool OnValidate <TEntity>(TEntity entity, AbstractValidator <TEntity> validator) { ValidationResult = validator.Validate(entity); return(IsValid); }
public bool Validate <TModel>(TModel model, AbstractValidator <TModel> validator) { ValidationResult = validator.Validate(model); return(Valid = ValidationResult.IsValid); }
protected void Validate <TEntity>(TEntity entity, AbstractValidator <TEntity> validator) => ValidationResult = validator.Validate(entity);
public ValidationResult SelfValidate() { return(isDirty ? TaskValidator.Validate(this) : null); }
public void ValidateNow <T>(AbstractValidator <T> validator, T instance) { var falhaValidacao = validator.Validate(instance); setValidation(falhaValidacao); }
protected bool Validate <TModel>(TModel model, AbstractValidator <TModel> validator) { this.ValidationResult = validator.Validate(model); return(IsValid = ValidationResult.IsValid); }
public ValidationResult Validate() { return(_validator.Validate(this)); }
public async Task <CardViewDTO> UpdateContent(CardContentDTO updatedCard, Guid userId) { var validationResult = _cardContentValidator.Validate(updatedCard); if (!validationResult.IsValid) { throw new Exception(validationResult.ToString()); } else { Card card = await _cardRepository.GetOne(updatedCard.Id); Column column = await _columnRepository.GetOne(card.ColumnId); var oldCard = await _cardRepository.GetOne(updatedCard.Id); card.UpdatedDate = DateTime.Now; if (oldCard.Text == null && updatedCard.Text != null) { card.Text = updatedCard.Text; var historyObject = await _historyService.CreateHistoryObject( UserActions.AddedDescription, userId, card.Title, null, null, column.BoardId ); } if (oldCard.Text != null && updatedCard.Text != oldCard.Text) { card.Text = updatedCard.Text; var historyObject = await _historyService.CreateHistoryObject( UserActions.EditedDescription, userId, card.Title, null, null, column.BoardId ); } if (oldCard.ExecutionPeriod != updatedCard.ExecutionPeriod) { card.ExecutionPeriod = updatedCard.ExecutionPeriod; var historyObject = await _historyService.CreateHistoryObject( UserActions.ChangeExecutionPeriod, userId, card.Title, null, null, column.BoardId ); } var result = await _cardRepository.Update(card); var mapperResult = _mapper.Map <Card, CardViewDTO>(result); return(mapperResult); } }
public ValidationResult Validate(TModel instance) { return(_validator.Validate(instance)); }
protected void InsertValidation <TViewModel>(TViewModel model, AbstractValidator <TViewModel> validator) where TViewModel : ViewModel => ValidationResult = validator.Validate(model);
protected override async Task HandleCore(CreateApprenticeshipUpdateCommand command) { var validationResult = _validator.Validate(command); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } if (await _apprenticeshipUpdateRepository.GetPendingApprenticeshipUpdate(command.ApprenticeshipUpdate.ApprenticeshipId) != null) { throw new ValidationException("Unable to create an ApprenticeshipUpdate for an Apprenticeship with a pending update"); } var apprenticeship = await _apprenticeshipRepository.GetApprenticeship(command.ApprenticeshipUpdate.ApprenticeshipId); var commitment = await _commitmentRepository.GetCommitmentById(apprenticeship.CommitmentId); if (!ValidateStartedApprenticeship(apprenticeship, command.ApprenticeshipUpdate)) { throw new ValidationException("Unable to create an update for an apprenticeship that is already started "); } CheckAuthorisation(command, apprenticeship); await Task.WhenAll( CheckOverlappingApprenticeships(command, apprenticeship), CheckReservation(command.ApprenticeshipUpdate, apprenticeship)); Apprenticeship immediateUpdate = null; ApprenticeshipUpdate pendingUpdate = null; if (HasImmediateUpdate(command)) { StartHistoryTracking(commitment, apprenticeship, command.Caller.CallerType, command.UserId, command.UserName); MapImmediateApprenticeshipUpdate(apprenticeship, command); immediateUpdate = apprenticeship; } if (apprenticeship.StartDate == null) { throw new InvalidOperationException($"The start date on apprenticeship {apprenticeship.Id} is null when calling {nameof(CreateApprenticeshipUpdateCommand)} command handler"); } if (command.ApprenticeshipUpdate.HasChanges) { pendingUpdate = command.ApprenticeshipUpdate; pendingUpdate.EffectiveFromDate = apprenticeship.StartDate.Value; await SendApprenticeshipUpdateCreatedEvent(apprenticeship); } await Task.WhenAll( _apprenticeshipUpdateRepository.CreateApprenticeshipUpdate(pendingUpdate, immediateUpdate), SaveHistory(), _v2EventsPublisher.PublishApprenticeshipUlnUpdatedEvent(immediateUpdate) ); if (command.ApprenticeshipUpdate.ULN != null) { _apprenticeshipEventsList.Add(commitment, apprenticeship, "APPRENTICESHIP-UPDATED", _currentDateTime.Now); await _apprenticeshipEventsPublisher.Publish(_apprenticeshipEventsList); } }
protected ValidationResult Validate(T entity, AbstractValidator <T> validator) => validator.Validate(entity);
public void Validate <TEntity>(TEntity entity, AbstractValidator <TEntity> validator) where TEntity : Entity { ValidationResult = validator.Validate(entity); Valid = ValidationResult.IsValid; }
public bool Validate <TEntity>(TEntity model, AbstractValidator <TEntity> validator) { ValidationResult = validator.Validate(model); return(IsValid = ValidationResult.IsValid); }
private bool ValidateCommand() { var validationResult = _commandValidator.Validate(_command); return(validationResult.IsValid); }
public OverallValidationResult Validate(T login) { return(ValidationRules.Validate(login).ApplyResultsTo(RefrenceTypeValidatables)); }
/// <summary> /// Performs validation on this exchange visitor and returns the validation result. /// </summary> /// <returns>The validation result.</returns> public ValidationResult Validate(AbstractValidator <ExchangeVisitor> validator) { Contract.Requires(validator != null, "The validator must not be null."); return(validator.Validate(this)); }
public T Create(T entidad) { string id = Guid.NewGuid().ToString(); entidad.Id = id; ValidationResult validationResult = validator.Validate(entidad); if (validationResult.IsValid) { string sql1 = $"INSERT INTO {typeof(T).Name} ("; string sql2 = ") VALUES ("; string sql3 = ");"; var campos = typeof(T).GetProperties(); T dato = (T)Activator.CreateInstance(typeof(T)); Type tTipo = typeof(T); for (int i = campos.Length - 1; i >= 0; i--) { var propiedad = tTipo.GetProperty(campos[i].Name); var valor = propiedad.GetValue(entidad); if (valor == null) { continue; } sql1 += " " + campos[i].Name; switch (propiedad.PropertyType.Name) { case "String": sql2 += "'" + valor + "'"; break; case "DateTime": DateTime dateTime = (DateTime)valor; sql2 += $"'{dateTime.Year}-{dateTime.Month}-{dateTime.Day} {dateTime.Hour}: {dateTime.Minute}: {dateTime.Second}'"; break; case "Boolean": sql2 += ((bool)valor) ? "1" : "0"; break; default: sql2 += " " + valor; break; } if (i != 0) { sql1 += ", "; sql2 += ", "; } } if (db.Comando(sql1 + sql2 + sql3) == 1) { Error = ""; return(SearchById(id)); } else { Error = $"Error al construir el sql:{ db.Error}"; return(null); } } else { Error = "Error de validacion:"; foreach (var item in validationResult.Errors) { Error += item.ErrorMessage + ". "; } return(null); } }
public EntityValidationResult ValidateUserNotificationPreferences(UserNotificationPreferences preferences) { var fluentResult = _userNotificationPreferencesValidator.Validate(preferences); return(EntityValidationResult.FromFluentValidationResult(fluentResult)); }
public bool Validate <TValueObject>(TValueObject valueObject, AbstractValidator <TValueObject> validator) { ValidationResult = validator.Validate(valueObject); return(IsValid = ValidationResult.IsValid); }
public EntityValidationResult ValidateQualification(Qualification qualification) { ValidationResult fluentResult = _qualificationValidator.Validate(qualification); return(EntityValidationResult.FromFluentValidationResult(fluentResult)); }
public bool Validate <T> (T entity, AbstractValidator <T> validator) { ValidationResult = validator.Validate(entity); return(Valid = ValidationResult.IsValid); }
public bool Validade <T>(T command, AbstractValidator <T> validator) { ValidationResult = validator.Validate(command); return(IsValid = ValidationResult.IsValid); }