Skip to content

remove implicit empty string to null conversion in sanitize()#223

Merged
techmahedy merged 1 commit intodoppar:3.xfrom
techmahedy:techmahedy-3.x
Mar 11, 2026
Merged

remove implicit empty string to null conversion in sanitize()#223
techmahedy merged 1 commit intodoppar:3.xfrom
techmahedy:techmahedy-3.x

Conversation

@techmahedy
Copy link
Copy Markdown
Member

Previously, sanitize() silently converted '' to null for all models, causing unexpected NULL values in the database and potential NOT NULL constraint violations when developers explicitly passed empty strings.

The base implementation now only trims whitespace:

protected function sanitize($value)
{
    if (is_string($value)) {
        $value = trim($value);
    }
    return $value;
}

Developers who need their own required behavior can opt-in by overriding in their model:

@techmahedy techmahedy merged commit 6b5a3db into doppar:3.x Mar 11, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant