I am sorry but I am not sure what you mean by that.
When your API gives an error like Not valid!, you can test with Postman for the response body. It will look like this:
tests['testname'] = responseBody === 'Not Valid!'
Everytime this error appears the test will pass.
Lars
German developer, who likes to play with everything that comes in his way
I personally use Postman for this. It costs 10$ and you can write Tests with it, run Automatic tests. You can export the tests as JSON. Important thing to note is that this is only a Chrome extension.
With a command line tool called Newman from the same company you can run these tests from a console. In the command line you can run the JSON exports.