loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Model property typed object validation

Open jsheely opened this issue 9 years ago • 4 comments

Model properties that are a typed objects with validations do not fire validation.

Take these models

// Product
{
    "name": "product",
    "properties": {
        "name": {
            "type":"string",
            "required": true
        },
        "part": {
            "type":"part",
            "required": true
        }
    }
}
// Part
{
    "name":"part",
    "properties": {
        "price": {
            "type": "number",
            "required": true
        }
    }
}
(POST) /api/products
{
    "name":"Hello",
    "part": {
    }
}

I would expect to be given a 422 error stating that price is required on part.price

jsheely avatar Mar 20 '17 20:03 jsheely

@jsheely Loopback is not supporting nested validation. I am also facing the same issue.

padelagani avatar Mar 21 '17 07:03 padelagani

Exactly. I am closing this issue as a duplicate of #300

bajtos avatar Mar 21 '17 15:03 bajtos

I'm also suprised this doesn't work. If you want I'd be willing to make some changes to do nested validation... I presume a lot of people are having to hardcode - we do. If it is planned, do you have an ETA?

Let me know, either way.

bana-io avatar May 15 '17 22:05 bana-io

@mbana

If you want I'd be willing to make some changes to do nested validation... I presume a lot of people are having to hardcode - we do. If it is planned, do you have an ETA?

We don't have any plans to fix this issue in the near future. A contribution will be welcome!

Let's move further discussions to #300 please.

bajtos avatar May 22 '17 11:05 bajtos