Invalid inline value object with fields with invalid values

I created a Person object in Doctrine2, and I added an Adress object to it, which is a value (embeddable) object.

I want to allow the creation of Person without an address, so I mark my inline as "nullable = true". But, on the other hand, my address entity, if it exists, MUST contain at least some information (for example, city, zip code, etc.). Thus, it has the attributes "nullable = false".

Address:
    type: embeddable
    fields:
        [...]
        city:
            type: string
            length: 255
            nullable: false

Person:
    type: entity
    table: null
    embedded:
        address:
            class: Address
            nullable: true

It seems that the "nullable = true" inline object is not working. Do you know if this is the normal behavior of the Doctrine? Should I put all my nested attributes in nullable = true?

+4

Source: https://habr.com/ru/post/1616597/


All Articles