Skip to content

Conversation

jasonmccreary
Copy link
Collaborator

@jasonmccreary jasonmccreary commented Oct 25, 2022

Currently, Blueprint does not explicitly set the nullable validation rule for nullable columns. This means the generated form request requires nullable columns to be set or not in the request data at all.

For example, a published_at date column which is nullable would generate the validation rule ['date']. As such, attempting to set this published_at column to null would cause validation to fail. That is not the expected behavior for a nullable column.

Originally, the thought was the columns you passed to a validate statement should all be "required". While that is the common case, it's assuming (too fancy).

I now think adding the nullable validation rule to database columns which are nullable generates an expected set of ready-to-use validation rules. If the developer knows a nullable column is always present in the request or should not be null for that form, then it's easy to change to required.


Closes #431

@jasonmccreary jasonmccreary merged commit 5ba6c44 into master Oct 25, 2022
@jasonmccreary jasonmccreary deleted the nullable-rule branch October 25, 2022 18:42
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.

Option to generate nullable rules in FormRequest
1 participant