8000 Existing attributes for validation are not JSON serialized, so rules can fail · Issue #576 · cloudcreativity/laravel-json-api · GitHub
[go: up one dir, main page]

Skip to content
Existing attributes for validation are not JSON serialized, so rules can fail #576
Closed
@lindyhopchris

Description

@lindyhopchris

For an update request, the validators uses the schema to get the 5429 existing attributes of a resource. When doing this, it will call the schema's getAttributes() method directly.

This means the values are not serialized, which means the value of an attribute may not match the expected values from a client.

Take dates for example. The validation rules will be expecting the client to provide date strings, as there is no date object in JSON. The schema could correctly be returning Carbon date objects in its getAttributes method, as these would be converted to strings when passed into json_encode. However, this means when the validator is working out the existing attributes, the values are date objects, not strings. This causes the ISO8601 rule from this package to fail.

This isn't the fault of the rule - it is right to expect date strings.

We should probably json_encode then json_decode the current attributes when getting them from the schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0