-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Record for dto + bedre validering (TFP-5612)
- Loading branch information
Showing
3 changed files
with
17 additions
and
30 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/main/java/no/nav/foreldrepenger/los/felles/util/RegexPatterns.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package no.nav.foreldrepenger.los.felles.util; | ||
|
||
public class RegexPatterns { | ||
|
||
public static final String ENHETSNUMMER = "\\d{4}"; | ||
|
||
private RegexPatterns() { | ||
throw new IllegalAccessError("Skal ikke instansieres"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 6 additions & 29 deletions
35
src/main/java/no/nav/foreldrepenger/los/tjenester/admin/dto/DriftAvdelingEnhetDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,19 @@ | ||
package no.nav.foreldrepenger.los.tjenester.admin.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
import no.nav.foreldrepenger.los.felles.util.RegexPatterns; | ||
import no.nav.vedtak.sikkerhet.abac.AbacDataAttributter; | ||
import no.nav.vedtak.sikkerhet.abac.AbacDto; | ||
import no.nav.vedtak.util.InputValideringRegex; | ||
|
||
import java.util.Objects; | ||
|
||
public class DriftAvdelingEnhetDto implements AbacDto { | ||
|
||
@JsonProperty("avdelingEnhet") | ||
@NotNull | ||
@Pattern(regexp = InputValideringRegex.FRITEKST) | ||
private final String avdelingEnhet; | ||
|
||
public DriftAvdelingEnhetDto() { | ||
avdelingEnhet = null; // NOSONAR | ||
} | ||
|
||
public DriftAvdelingEnhetDto(String avdelingEnhet) { | ||
Objects.requireNonNull(avdelingEnhet, "avdelingEnhet"); | ||
this.avdelingEnhet = avdelingEnhet; | ||
} | ||
|
||
public String getAvdelingEnhet() { | ||
return avdelingEnhet; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AvdelingEnhetDto{" + "avdelingEnhet='" + avdelingEnhet + '\'' + '}'; | ||
} | ||
|
||
public record DriftAvdelingEnhetDto(@JsonProperty("avdelingEnhet") | ||
@NotNull | ||
@Pattern(regexp = RegexPatterns.ENHETSNUMMER) | ||
String avdelingEnhet) implements AbacDto { | ||
@Override | ||
public AbacDataAttributter abacAttributter() { | ||
return AbacDataAttributter.opprett(); | ||
} | ||
} | ||
|