Skip to content
Snippets Groups Projects
Commit e536d11f authored by Alžbeta Hajná's avatar Alžbeta Hajná
Browse files

feat(core): validaion annotations

parent 41a54a2e
No related branches found
No related tags found
2 merge requests!54Merge develop into main,!36Validation
...@@ -4,6 +4,8 @@ import cz.muni.pa165.data.enums.ComponentTypeEnum; ...@@ -4,6 +4,8 @@ import cz.muni.pa165.data.enums.ComponentTypeEnum;
import jakarta.annotation.Nonnull; import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Positive;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
...@@ -18,9 +20,10 @@ public class CarComponent extends DomainObject implements Serializable { ...@@ -18,9 +20,10 @@ public class CarComponent extends DomainObject implements Serializable {
private ComponentTypeEnum componentType; private ComponentTypeEnum componentType;
@Nonnull @Nonnull
@Positive
private Double weight; private Double weight;
@Nonnull @NotEmpty
private String information; private String information;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
......
...@@ -3,6 +3,7 @@ package cz.muni.pa165.data.model; ...@@ -3,6 +3,7 @@ package cz.muni.pa165.data.model;
import jakarta.annotation.Nonnull; import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
...@@ -12,7 +13,7 @@ import java.util.Set; ...@@ -12,7 +13,7 @@ import java.util.Set;
@Table(name = "department") @Table(name = "department")
public class Department extends DomainObject implements Serializable { public class Department extends DomainObject implements Serializable {
@Nonnull @NotEmpty
private String specialization; private String specialization;
@OneToMany(fetch = FetchType.LAZY, @OneToMany(fetch = FetchType.LAZY,
......
...@@ -4,6 +4,10 @@ import cz.muni.pa165.data.enums.CharacteristicsEnum; ...@@ -4,6 +4,10 @@ import cz.muni.pa165.data.enums.CharacteristicsEnum;
import jakarta.annotation.Nonnull; import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Past;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -14,19 +18,22 @@ import java.util.Set; ...@@ -14,19 +18,22 @@ import java.util.Set;
@Table(name = "driver") @Table(name = "driver")
public class Driver extends DomainObject implements Serializable { public class Driver extends DomainObject implements Serializable {
@Nonnull @NotEmpty
private String name; private String name;
@Nonnull @NotEmpty
private String surname; private String surname;
@Nullable @Nullable
@Min(100)
@Max(300)
private Integer height; private Integer height;
@Nullable @Nullable
@Past
private LocalDate birthday; private LocalDate birthday;
@Nonnull @NotEmpty
private String nationality; private String nationality;
@ElementCollection(targetClass = CharacteristicsEnum.class) @ElementCollection(targetClass = CharacteristicsEnum.class)
......
...@@ -3,6 +3,7 @@ package cz.muni.pa165.data.model; ...@@ -3,6 +3,7 @@ package cz.muni.pa165.data.model;
import jakarta.annotation.Nonnull; import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
...@@ -11,10 +12,10 @@ import java.util.Objects; ...@@ -11,10 +12,10 @@ import java.util.Objects;
@Table(name = "engineer") @Table(name = "engineer")
public class Engineer extends DomainObject implements Serializable { public class Engineer extends DomainObject implements Serializable {
@Nonnull @NotEmpty
private String name; private String name;
@Nonnull @NotEmpty
private String surname; private String surname;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment