## Validation and Default Values

For all API operations that change configuration state, there are corresponding Validation APIs. For example, the API:

        POST [apiRoot]/Tenants

has a corresponding validation API at:

        POST [apiRoot]/Tenants/Validate

You may call this validation API with complete, partial, or even empty data content. The validation APIs do not modify configuration state, but rather:

- Any data content not specified will be filled with the default values, if any default value exists. The caller is returned the complete data content including default values.
- Any validation errors on the complete set of validated data (including default values) will be returned as well.

Callers should not assume validation rules or default values will remain constant across App Orchestration releases, but rather, should always call the API to obtain this information.

An example request calling a validation API with empty data content:

        POST https://srv01.my.com/cam/api/v1/DataCenters/$validate HTTP/1.1
        Host: srv01.my.com
        Content-Length: 2
        Cookie: CamApiSessionId=_J8YFJ_lCB5YSju8x9NACGHavYpgDjISMQr0sT QgoSO3F8OLywzxOGsAAfdXGL9LJ4KOB8tv0pKkwhAYDLKyQ; XSRF TOKEN=c0g5npWs3bq34AfPX i4WR7yJ71sMUqBCoWHWNAjw72G1vsVHmYd85u8VaLJBX9SJnXZ5RhqZ28aJbLuBWykbg

        {}

Response:

        HTTP/1.1 200 OK
        Cache-Control: private
        Content-Length: 359
        Content-Type: application/json; charset=utf-8
        Set Cookie: CamApiSessionId=30_fuILN2i2Tq6 F3joJCeFxRp4NW2jVI2XVZOwTvegnhngfZ6RtsfZdivsHJpt_O4qTzGNO1qinJR5DGx8MJg; Max Age=1800; Domain=srv01.my.com; Path=/cam/api/v1/; HttpOnly; Secure
        Set Cookie: XSRF TOKEN=iytz3 PxXcHza4BWb5Dm3bNid2UGIWGHvOuBTzba9STzpxZe631OySMkb7Fj_PEDT1i9siiLCUj2 n9hWvByTQ; Max Age=1800; Domain=srv01.my.com; Path=/; Secure

        {
            "Errors": [{
                "ErrorCode": "Required",
                "ErrorMessage": "Required.",
                "MemberNames": ["Name"]
            }],
            "Input": {
                "AccessGatewayAddress": null,
                "LicenseServerAddress": "ctxlicense.my.com",
                "Name": null,
                "ShortName": null
            }
        }

This response indicates that there is one error: the `Name` field is required. It also returns the input object, with any defaults that can be provided based on the input; in this case, the `LicenseServerAddress` field has a default.

Continuing this example, imagine the caller specifies the Name field in the request:

        POST https://srv01.my.com/cam/api/v1/DataCenters/$validate HTTP/1.1
        Host: srv01.my.com
        Content-Length: 13
        Cookie: CamApiSessionId=_J8YFJ_lCB5YSju8x9NACGHavYpgDjISMQr0sT QgoSO3F8OLywzxOGsAAfdXGL9LJ4KOB8tv0pKkwhAYDLKyQ; XSRF TOKEN=c0g5npWs3bq34AfPX i4WR7yJ71sMUqBCoWHWNAjw72G1vsVHmYd85u8VaLJBX9SJnXZ5RhqZ28aJbLuBWykbg

        {"Name":"us"}

Response:

        HTTP/1.1 200 OK
        Cache-Control: private
        Content-Length: 284
        Content-Type: application/json; charset=utf-8
        Set Cookie: CamApiSessionId=30_fuILN2i2Tq6 F3joJCeFxRp4NW2jVI2XVZOwTvegnhngfZ6RtsfZdivsHJpt_O4qTzGNO1qinJR5DGx8MJg; Max Age=1800; Domain=srv01.my.com; Path=/cam/api/v1/; HttpOnly; Secure
        Set Cookie: XSRF TOKEN=iytz3 PxXcHza4BWb5Dm3bNid2UGIWGHvOuBTzba9STzpxZe631OySMkb7Fj_PEDT1i9siiLCUj2 n9hWvByTQ; Max Age=1800; Domain=srv01.my.com; Path=/; Secure

        {
            "Errors": [],
            "Input": {
                "AccessGatewayAddress": "https://ag.us.my.com",
                "LicenseServerAddress": "ctxlicense.my.com",
                "Name": "us",
                "ShortName": "us"
            }
        }

Now, the input has no errors, and all four fields have defaults. Since the `Name` was specified, the system was able to generate default values for both the `AccessGatewayAddress` and `ShortName` fields.

For more details on the contents of the validation response, see ValidationResultModel.