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

# Parameter Validation

Many `nf-core` workflows use the `nf-validation` package to validate input parameters. To prevent workflows from failing at runtime
due to invalid parameter values, the Latch SDK provides a way to use regex to validate inputs before the workflow is launched.

Developers can easily add parameter validation to their workflows adding the `rules` field to the `NextflowParameter` that requires
validation. For example:

```python theme={null}
from latch.types.metadata import NextflowParameter, LatchRule
from latch.types.directory import LatchFile

from pathlib import Path

generated_parameters = {
  'fastq': NextflowParameter(
    type=LatchFile,
    rules=[
      LatchRule(
        # only allow file paths that do not contain spaces
        regex=r"^[^\s]+$",
        # error message to display if the regex fails
        message="File path cannot contain spaces."
      )
    ],
  )
}
```

In the example above, the `fastq` parameter is validated to ensure that the file path does not contain spaces. If the regex fails,
the error message "File path cannot contain spaces." is displayed to the user.

<img src="https://mintcdn.com/latchbio/uN1BKX4g3v1ZQv8l/images/workflows/nextflow/param-validation.png?fit=max&auto=format&n=uN1BKX4g3v1ZQv8l&q=85&s=ca07b076ef9198c4bb13e4ac6f717c7f" className="h-56 border-slate-100 border rounded-md" width="1164" height="470" data-path="images/workflows/nextflow/param-validation.png" />


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