Skip to content

Commit

Permalink
refactor: make MetadataBlock name regex a public constant #8085
Browse files Browse the repository at this point in the history
  • Loading branch information
poikilotherm committed Sep 6, 2021
1 parent 71faf25 commit 7289ff6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/MetadataBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
@Entity
public class MetadataBlock implements Serializable {

public static final String BLOCK_NAME_REGEX = "^[a-z][\\w]+$";

/**
* Reusable definition of headers used for parsing this model class from data (TSV, JSON, manual, ...)
* Using the Headers.Constants class to work around annotations not able to use enum values (a Java limitation).
Expand Down Expand Up @@ -98,7 +100,7 @@ public String getName() {

@Parsed(field = Headers.Constants.NAME)
// Docs: No spaces or punctuation, except underscore. By convention, should start with a letter, and use lower camel case
@Validate(matches = "^[a-z][\\w]+$")
@Validate(matches = BLOCK_NAME_REGEX)
public void setName(String name) {
this.name = name;
}
Expand Down

0 comments on commit 7289ff6

Please sign in to comment.