Validating Fields
Each object that allows write access (create or update) will also provide a validate method to validate field values.
The validate method takes a partial object as a parameter. it will validate the value of each field that is passed. A list of validation errors is returned.
Note that some validations that check relationships with other objects or that span more than one field cannot be checked during the validate method call. For these cases, create or update may still encounter errors on data that validate considers correct.
Calling the Validate Method
Here is an example request calling the application.validate method. Here, the name field is validated. The result of true indicates the name was valid.
A JSON-RPC Request for calling the validate method
{ "method": "application.validate", "params": [ { "name": "new_application_name" } ], "id": 1 }
The JSON-RPC Response for valid data
{ "result": true, "error": null, "id": 1 }
Validation Errors
If there is an error in the data passed, an invalid object error message will be returned.
A JSON-RPC Request for calling the validate method
Here is an example request calling the application.validate method, but with invalid data.
{ "method": "application.validate", "params": [ { "name": "" } ], "id": 1 }
The JSON-RPC Response
{ "result": null, "error": { "message": "Invalid Object", "code": 1000, "data": [ { "field": "name", "message": "This value is not allowed to be blank." } ] }, "id": 1 }
Docs Navigation
- API Documentation Portal
- IO Docs Definition
- Mashery API Documentation
- Mashery 3.0 API Guide
- Mashery 2.0 API Guide
- OAuth Supporting Methods
- Examples
- JSON RPC
- Authentication
- API Objects
- Fetching Objects
- Query Language
- Creating Objects
- Updating Objects
- Validating Fields
- Deleting Objects
- Applications
- General Object Methods
- Members
- Packages
- Plans
- Package Keys
- Keys
- Developer Classes
- Services
- Roles
- Mashery 2.0 Reporting API Guide
- Event Trigger API
- Differences between Roles and Portal Access Groups
- Managing a Portal Access Group Using Mashery V2 or V3 API
- Mashery Reporting Event Post API Guide
- Tips and Tricks
- Your Portal
- API Traffic Manager
- I/O Docs WSDL requirements