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

OPN-413: add validation for the 'year' field #1136

Open
wants to merge 1 commit into
base: reclassification-changes
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions ckanext/canada/tables/reclassification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,33 +288,7 @@ resources:
validation: This field must not be empty
excel_column_width: 10
extract_date_year: true
choices:
2020: "2020"
2019: "2019"
2018: "2018"
2017: "2017"
2016: "2016"
2015: "2015"
2014: "2014"
2013: "2013"
2012: "2012"
2011: "2011"
2010: "2010"
2009: "2009"
2008: "2008"
2007: "2007"
2006: "2006"
2005: "2005"
2004: "2004"
2003: "2003"
2002: "2002"
2001: "2001"
2000: "2000"
1999: "1999"
1998: "1998"
1997: "1997"
1996: "1996"
1995: "1995"
excel_error_formula: '{cell}>YEAR(TODAY())'

- datastore_id: quarter
datastore_type: text
Expand Down Expand Up @@ -374,6 +348,9 @@ resources:
errors := errors || choice_error(NEW.year::text, {year}, 'year');
errors := errors || required_error(NEW.quarter, 'quarter');
errors := errors || choice_error(NEW.quarter, {quarter}, 'quarter');
IF NEW.year > date_part('year', CURRENT_DATE) THEN
errors := errors || ARRAY[['year', 'This must list the year you are reporting on (not the fiscal year).']];
END IF;
IF errors = '{{}}' THEN
RETURN NEW;
END IF;
Expand Down