## validateResourceType() function

Validates that the given string is a valid FHIR resource type.

On success, silently returns void. On failure, throws an OperationOutcomeError.

**Signature:**

```typescript
export declare function validateResourceType(resourceType: string): void;
```

## Parameters

| Parameter     | Type    | Description                            |
|---------------|---------|----------------------------------------|
| resourceType  | string  | The candidate resource type string.   |

**Returns:**

void

## Example 1

```ts
validateResourceType('Patient'); // nothing

validateResourceType('XYZ'); // throws OperationOutcomeError
```

Note that this depends on `globalSchema`, which is populated by the StructureDefinition loader.

## Example 2

In a server context, you can load all schema definitions:

```ts
import { indexStructureDefinitionBundle } from '@medplum/core';

import { readJson } from '@medplum/definitions';

import { Bundle } from '@medplum/fhirtypes';

indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);
```

## Example 3

In a client context, you can load the schema definitions using `MedplumClient`:

```ts
import { MedplumClient } from '@medplum/core';

const medplum = new MedplumClient();

await medplum.requestSchema('Patient');
```

- [validateResourceType() function](/content/docs/sdk/core.validateresourcetype#validateresourcetype-function/index.html)
- [Parameters](/content/docs/sdk/core.validateresourcetype#parameters/index.html)
- [Example 1](/content/docs/sdk/core.validateresourcetype#example-1/index.html)
- [Example 2](/content/docs/sdk/core.validateresourcetype#example-2/index.html)
- [Example 3](/content/docs/sdk/core.validateresourcetype#example-3/index.html)
