API Reference
    Preparing search index...

    Error thrown when a schema validation fails.

    This error is thrown when the validation of a payload against a schema fails, the cause property contains the original Ajv issues.

    import { validate } from '@aws-lambda-powertools/validation';
    import { ValidationError } from '@aws-lambda-powertools/validation/errors';

    const schema = {
    type: 'number',
    minimum: 0,
    maximum: 100,
    };

    const payload = -1;

    try {
    validate({ payload, schema });
    } catch (error) {
    if (error instanceof ValidationError) {
    // cause includes the original Ajv issues
    const { message, cause } = error;
    // ... handle the error
    }

    // handle other errors
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Constructors