8

The biber/biblatex data model allows the user to specify constraints on the data model with \DeclareDatamodelConstraints. In the default data model defined by blx-dm.def there is:

\DeclareDatamodelConstraints[article]{
  \constraint[type=mandatory]{
    \constraintfield{author}
    \constraintfield{journaltitle}
    \constraintfield{title}
  }
}

As far as I can tell, the constraint does not do anything. Consider the following MWE:

\documentclass{article}
\usepackage{biblatex}

\begin{filecontents*}{\jobname.bib}
@article{myarticle,
  title = {Some Title}
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
  \cite{myarticle}
\printbibliography
\end{document}

If I run it through pdflatex, biber, pdflatex, I expect biber to stop, or at a minimum complain loudly, that a constraint is not met, but I do not see anything in either the log or blg files to suggest that the constraint is not being met. Is it possible to define constraints such that biber/pdflatex will complain if they are not met?

11

To have these constraints checked you need to pass the --validate_datamodel option to biber. On your example running

biber --validate_datamodel file

I get

[...]
WARN - Datamodel: Entry 'myarticle' (file.bib): Missing mandatory field - one of 'date, year' must be defined
WARN - Datamodel: Entry 'myarticle' (file.bib): Missing mandatory field 'author'
WARN - Datamodel: Entry 'myarticle' (file.bib): Missing mandatory field 'journaltitle'
[...]
INFO - WARNINGS: 3

If you wish, you can set this option in a biber.conf file consisting of

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <validate_datamodel>1</validate_datamodel>
</config>

instead of writing the command line option to biber each time.

0

If you change the constraints of existing fields don't forget to call

\ResetDatamodelConstraints

before defining your own constraints.

  • That is a valid observation. I'm just not sure whether it warrants being an "answer" here. The real issue is that one needs to set the option to validate the data model. Only if one writes a custom data model \ResetDatamodelConstraints comes into play. Maybe you can find another question where your observation is the real answer, here I think a comment would be better suited (although I appreciate that due to the reputation system you cannot currently comment everywhere). – moewe Jan 5 '16 at 8:57
  • @moewe: Yes, ineed this would be better suited to be a comment to the accepted answer but I don't have enough reputation. – t-b Jan 8 '16 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.