validate<T> method

T validate<T>()

to validate the wit dto ! throw BadRequest exception

Implementation

T validate<T>() {
  /// build dto from the request body
  final dto = buildDto<T>(body);

  /// validate the dto
  final errs = validateDto(dto as Object);

  /// in case of any failure throw exception
  if (errs.isNotEmpty) {
    throw BadRequest(data: errs);
  }

  /// else every thing is fine return the dto
  return dto;
}