From 9158ad5b8e8acf3253f5a4c96eda50dd1fcea44d Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Fri, 15 Mar 2013 17:20:07 +0100 Subject: [PATCH] reporting: @page: check user input --- matlab/reporting/@page/page.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/matlab/reporting/@page/page.m b/matlab/reporting/@page/page.m index 5882b518d8..20af0b8ff8 100644 --- a/matlab/reporting/@page/page.m +++ b/matlab/reporting/@page/page.m @@ -60,6 +60,25 @@ elseif nargin > 1 end end +% Check options provided by user +assert(ischar(o.title), '@page.page: title must be a string'); + +valid_paper = {'a4', 'letter'}; +assert(any(strcmp(o.paper, valid_paper)), ... + ['@page.page: paper must be one of ' strjoin(valid_paper, ' ')]); + +valid_orientation = {'portrait', 'landscape'}; +assert(any(strcmp(o.orientation, valid_orientation)), ... + ['@page.page: orientation must be one of ' strjoin(valid_orientation, ' ')]); + +msg = ['@page.page: footnote must be a cell array of string(s)']; +if ~isempty(o.footnote) + assert(iscell(o.footnote), msg); + for i=1:length(o.footnote) + assert(ischar(o.footnote{i}), msg); + end +end + % Create page object o = class(o, 'page'); end -- GitLab