'How to compare a string to a date in postman test?

Suppose a API request fetches a users id, email address and birthday. Sample API Request below:

GET: /v1/users HTTP/1.1
Content-Type: application/json
Authorization: bearer {access_token}

For the above request, the following is the response:

{
    "content": [
        {
            "id": 1,
            "email": "[email protected]",
            "birthday": "1990-01-01"
        },
        {
            "id": 40,
            "email": "[email protected]",
            "birthday": "1990-18-10"
        }
],
    "last": false,
    "total_elements": 2,
    "total_pages": 1,
    "sort": null,
    "first": true,
    "number_of_elements": 2,
    "size": 20,
    "number": 0
}

Now, what will be the test in postman to make sure that all the returned values under birthday node is greater than 1988-18-01?

I have tried the following:

pm.test("Check birthday greater than 1988-18-01", () => {
    for (i = 0; i < jsonData.content.length; i++) {
        var a = '1988-18-01'; 
        pm.expect(jsonData.content[i].birthday).to.be.above(a);
    }
});

But postman says: "Check birthday greater than 1988-18-01 | AssertionError: expected '1990-01-01' to be a number or a date".



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source