Skip to content

Validation#141

Merged
rossjones merged 6 commits intomainfrom
validation
Feb 3, 2025
Merged

Validation#141
rossjones merged 6 commits intomainfrom
validation

Conversation

@alaric-rd
Copy link
Contributor

Added a validation mechanism, invoke by providing attribute type validators when setting up the import mapping.

If none are specified, it defaults to everything being strings with no validation, matching current behaviour.

The mapping results may now include errors that cause input rows to be rejected, or warnings where a row could be interpreted but there might be a problem with it (eg, an attribute value was malformed for the required type, but it was marked as optional anyway so we can live without it).

Adding support to display these warnings/errors in the frontend will be a separate bit of work.

@alaric-rd alaric-rd requested a review from rossjones January 16, 2025 11:01
// undefined values and maps then to "undefined", and converts any validation errors to warnings
exports.optionalType = (baseType) => {
return (inputValue) => {
if(inputValue !== undefined && inputValue != "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want/need to check for null as well?

// Create a required version of an existing type, that reports an undefined or empty-string input value as an error
exports.requiredType = (baseType) => {
return (inputValue) => {
if(inputValue !== undefined && inputValue != "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dupe comment, null check?

@rossjones rossjones merged commit 7e7d0c4 into main Feb 3, 2025
5 checks passed
@rossjones rossjones deleted the validation branch February 3, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants