Add string checks to VOs
continuous-integration/drone/push Build is passing Details

This commit is contained in:
qvalentin 2022-03-29 11:04:47 +02:00
parent 43956ff10c
commit d091772002
Signed by: qvalentin
GPG Key ID: C979FA1EAFCABF1C
4 changed files with 20 additions and 7 deletions

View File

@ -7,9 +7,8 @@ public class Main {
public static void main(String[]args){
TagName a = new TagName("ds");
System.out.println("Schnauze");
TagName test = new TagName("ds");
System.out.println(test);
}
}

View File

@ -1,7 +1,7 @@
package link;
import category.CategoryId;
import tag.TagMatcher;
import tag.Tag;
import user.Username;
import java.util.Set;
@ -12,9 +12,9 @@ public class Link {
private final Username creator;
private final LinkUrl url;
private final Set<CategoryId> categoryIds;
private final Set<TagMatcher> tags;
private final Set<Tag> tags;
public Link(LinkId id, Username creator, LinkUrl url, Set<CategoryId> categoryIds, Set<TagMatcher> tags) {
public Link(LinkId id, Username creator, LinkUrl url, Set<CategoryId> categoryIds, Set<Tag> tags) {
this.id = id;
this.creator = creator;
this.url = url;

View File

@ -1,5 +1,12 @@
package tag;
import exeptions.IllegalValueObjectArgument;
public record TagName(String name) {
public TagName {
if (name.isEmpty() || name.isBlank()) {
throw new IllegalValueObjectArgument("A Tag name must be a valid non-empty string.");
}
}
}

View File

@ -1,5 +1,12 @@
package user;
import exeptions.IllegalValueObjectArgument;
public record Username(String username) {
//TODO: checks if username is valid
public Username {
if (username.isBlank() || username.isEmpty()) {
throw new IllegalValueObjectArgument("A username must be a valid non-empty string.");
}
}
}