|
| 1 | +DOE CODE Validation Services |
| 2 | +===================== |
| 3 | + |
| 4 | +Introduction |
| 5 | +------------ |
| 6 | +Access various validation checks for DOE CODE API data. HTTP verb `GET` performs various |
| 7 | +single value checks, or use HTTP `POST` to send a batch of validation requests at once. |
| 8 | + |
| 9 | +> The API is available based on `/doecodeapi/services/docs/validation` on the DOE CODE server. |
| 10 | +
|
| 11 | +HTTP Request Methods |
| 12 | +-------------------- |
| 13 | + |
| 14 | +| Method | Description | |
| 15 | +| --- | --- | |
| 16 | +| `GET` | Used to retrieve resources | |
| 17 | +| `POST` | Send a batch of requests | |
| 18 | +| `PUT` | *Not currently used* | |
| 19 | +| `DELETE` | *Not currently used* | |
| 20 | + |
| 21 | +Service Endpoints |
| 22 | +----------------- |
| 23 | + |
| 24 | +## Individual Validation Checks |
| 25 | + |
| 26 | +Each various type of validation may be performed via single `GET` requests from the |
| 27 | +following endpoints. Each share a common set of response codes, detailed below. |
| 28 | + |
| 29 | +| Response Code | Description | |
| 30 | +| --- | --- | |
| 31 | +| 200 | OK, value validates successful | |
| 32 | +| 400 | Bad Request, value is not valid for the requested type | |
| 33 | + |
| 34 | +Responses are also common to each of these individual valiation endpoints, all will |
| 35 | +be of the form shown. An example of success and failure for email validation is |
| 36 | +shown here. |
| 37 | + |
| 38 | +> Success: |
| 39 | +```html |
| 40 | +HTTP/1.1 200 OK |
| 41 | +Content-Type: application/json |
| 42 | +``` |
| 43 | +```json |
| 44 | +{ "value":"OK" } |
| 45 | +``` |
| 46 | +> Failure: |
| 47 | +```html |
| 48 | +HTTP/1.1 400 Bad Request |
| 49 | +Content-Type: application/json |
| 50 | +``` |
| 51 | +```json |
| 52 | +{"status":400,"errors":["\"value\" is not a valid email address."]} |
| 53 | +``` |
| 54 | + |
| 55 | +### phonenumber |
| 56 | + |
| 57 | +`GET /doecodeapi/services/validation/phonenumber?value=*value-to-check*` |
| 58 | + |
| 59 | +Attempt to validate a phone number for validity. |
| 60 | + |
| 61 | +### email |
| 62 | + |
| 63 | +`GET /doecodeapi/services/validation/email?value=*value-to-check*` |
| 64 | + |
| 65 | +Attempt to valid email address against recognized common patterns. |
| 66 | + |
| 67 | +### awardnumber |
| 68 | + |
| 69 | +`GET /doecodeapi/services/validation/awardnumber?value=*value-to-check*` |
| 70 | + |
| 71 | +Check to see if the value is a valid DOE contract/award number. |
| 72 | + |
| 73 | +### url |
| 74 | + |
| 75 | +`GET /doecodeapi/services/validation/url?value=*value-to-check*` |
| 76 | + |
| 77 | +Check to see if value is a valid URL-pattern; note this *does not* attempt to |
| 78 | +connect to the URL. |
| 79 | + |
| 80 | +### repositorylink |
| 81 | + |
| 82 | +`GET /doecodeapi/services/validation/repositorylink?value=*value-to-check*` |
| 83 | + |
| 84 | +Check to see if the indicated value is a valid, accessible git repository. DOE CODE does not currently support the submission of individual branch URL paths, so this must be a primary or base URL for the repository. |
| 85 | + |
| 86 | +### doi |
| 87 | + |
| 88 | +`GET /doecodeapi/services/validation/doi?value=*value-to-check*` |
| 89 | + |
| 90 | +Check to see if the value represents a live DOI value. |
| 91 | + |
| 92 | +## Batch Validation Requests |
| 93 | + |
| 94 | +If multiple validation requests should be made at once, you may construct an array |
| 95 | +of JSON objects to process. Each of these will be checked and the results made |
| 96 | +available back with an error message if the individual check failed. |
| 97 | + |
| 98 | +### batch validation |
| 99 | + |
| 100 | +Requests should be constructed in this manner: |
| 101 | + |
| 102 | +```json |
| 103 | +[ { "value":"value-to-check", "type":"validation-to-perform" }, ... ] |
| 104 | +``` |
| 105 | + |
| 106 | +Where *value-to-check* is the desired field value, and *validation-to-perform* is one |
| 107 | +of: "doi", "repositorylink", "url", "phonenumber", "email", or "awardnumber". Responses |
| 108 | +will be the same object, with each adding an "error" attribute. The "error" value |
| 109 | +will be blank if the value was acceptable, or a message indicating the failure if not. |
| 110 | + |
| 111 | +> Request: |
| 112 | +```html |
| 113 | +POST /doecodeapi/services/validation |
| 114 | +Content-Type: application/json |
| 115 | +``` |
| 116 | +```json |
| 117 | +[ { "value":"sampleurl", "type":"url"}, |
| 118 | + { "value":"sampleemail", "type":"email"} ] |
| 119 | +``` |
| 120 | +> Response: |
| 121 | +```html |
| 122 | +HTTP/1.1 200 OK |
| 123 | +Content-Type: application/json |
| 124 | +``` |
| 125 | +```json |
| 126 | +[ {"value":"sampleurl", "type":"url", "error":"sampleurl is not a valid URL."}, |
| 127 | + {"value":"sampleemail", "type":"email", "error":"sampleemail is not a valid email address."}] |
| 128 | +``` |
0 commit comments