> ## Documentation Index
> Fetch the complete documentation index at: https://docs.revoengine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# util.validate()

> Public low-code contract, signatures and examples for util.validate.

## `util.validate()`

Validates a payload with the platform schema validator used by Endpoints.

Notes:

* Prefer enum/const, types, lengths, numeric bounds and supported date/time formats over regex when equivalent.
* Use regex only for a required text pattern; even simple patterns can materially increase Endpoint guard preparation time.
* Use profile: 'strict' for new schemas; omitted profiles retain legacy behavior.
* required controls presence, nullable controls null, and empty controls empty strings and arrays.
* Use additionalProperties: 'allow', 'strip' or 'reject' for unknown fields.
* Legacy whitelist: true retains unknown fields. With whitelist: false, whitelistErrors: false removes them; true reports errors.
* The result contains valid, errors, issues and value. Structured issues expose code, path, message and optional params.
* After success, use value so configured field removal is respected.
* Input, schema and execution limits apply; cyclic data is rejected. Capacity or execution failures can reject the Promise.

### Signature

```ts theme={null}
static validate(
      payload: any,
      schema: ValidatorSchemaInput,
    ): Promise<ValidationResult<any>>;
```

### Example

```ts theme={null}
const result = await util.validate(
  api.input()?.body,
  {
    profile: 'strict',
    additionalProperties: 'reject',
    schema: {
      type: 'object',
      required: true,
      objectSchema: [
        { property: 'status', schema: { type: 'string', required: true, enum: ['pending', 'ready'] } },
      ],
    },
  },
);
if (!result.valid) throw new Error('Invalid request');
const validatedInput = result.value;
```

See [all util methods](https://docs.revoengine.com/low-code/reference/util.md) or [runtime basics](https://docs.revoengine.com/low-code/overview.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.