Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Validation for different identifier namespaces #34

Open
darupp opened this issue Apr 10, 2019 · 1 comment
Open

Check Validation for different identifier namespaces #34

darupp opened this issue Apr 10, 2019 · 1 comment
Assignees
Labels

Comments

@darupp
Copy link
Collaborator

darupp commented Apr 10, 2019

We have lots of identifier namespaces such as issn, isbn, doi etc. I'm not sure whether they are validated or not. You can enter a regex in the namespace definition - is there a validation function active and where they get checked? If so, we should write regexes for the namespaces.

@hornmo
Copy link
Collaborator

hornmo commented Apr 10, 2019

There is a rudimentary regex validation in Identifier, but it is currently only working with a static list for a small selection of identifiers.

private static nameSpaceRules = [
"issn" : "^\\d{4}\\-\\d{3}[\\dX]\$",
"issnl" : "^\\d{4}\\-\\d{3}[\\dX]\$",
"eissn" : "^\\d{4}\\-\\d{3}[\\dX]\$",
"zdb" : "^\\d+\\-[\\dxX]\$"
]
static constraints = {
namespace (nullable:false, blank:false)
value (validator: { val, obj ->
if (!val || val.trim().size() == 0) {
return ['notNull']
}
def norm_id = Identifier.normalizeIdentifier(val)
def dupes = Identifier.findByNamespaceAndNormname(obj.namespace, norm_id)
if (dupes && dupes != obj) {
return ['notUnique']
}
if (nameSpaceRules[obj.namespace.value] && !(val ==~ nameSpaceRules[obj.namespace.value])) {
return ['illegalIdForm.' + obj.namespace.value ]
}
})
}

A better approach would be to use the pattern field from IdentifierNamespace, although this would also not encompass verifying check digits etc., not to mention ISBNs (hyphenation, 13vs10).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants