US06: Add a button for the owner create form to the owners list, fix bug where all whitespaces were considered valid input

This commit is contained in:
2020-04-05 18:14:03 +02:00
parent be37d5ce86
commit a01405e3cc
4 changed files with 4 additions and 3 deletions

View File

@@ -127,7 +127,7 @@ public class OwnerJdbcDao implements OwnerDao {
int changes = jdbcTemplate.update(connection -> {
PreparedStatement ps = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
ps.setString(1, owner.getName());
ps.setString(1, owner.getName().trim());
ps.setObject(2, owner.getCreatedAt());
ps.setObject(3, owner.getUpdatedAt());
return ps;

View File

@@ -12,7 +12,7 @@ import java.util.Map;
@Component
public class Validator {
public void validateNewOwner(Owner owner) throws ValidationException {
if(owner.getName() == null || owner.getName().isEmpty()) {
if(owner.getName() == null || owner.getName().isEmpty() || owner.getName().isBlank()) {
throw new ValidationException("Required value name missing");
}
}