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

# ST_IsValidReason

Returns text stating if the geometry is valid. If not, it provides a reason why it is invalid. The function can be invoked with just the geometry or with an additional flag. The flag alters the validity checking behavior. The flags parameter is a bitfield with the following options:

* 0 (default): Use usual OGC SFS (Simple Features Specification) validity semantics.
* 1: "ESRI flag", Accepts certain self-touching rings as valid, which are considered invalid under OGC standards.

<img src="https://mintcdn.com/wherobots/fqh3gPDE0J25Lra_/images/sql-functions/ST_IsValidReason/ST_IsValidReason.svg?fit=max&auto=format&n=fqh3gPDE0J25Lra_&q=85&s=387fe3e83567e932c6c67a3cbb9ad226" alt="ST_IsValidReason" width="400" height="120" data-path="images/sql-functions/ST_IsValidReason/ST_IsValidReason.svg" />

## Signatures

```sql theme={"system"}
ST_IsValidReason (A: Geometry)
```

```sql theme={"system"}
ST_IsValidReason (A: Geometry, flag: Integer)
```

## Parameters

<ParamField body="A" type="Geometry" required>
  The input geometry.
</ParamField>

<ParamField body="flag" type="Integer">
  The validation flag.
</ParamField>

## Return type

<ResponseField type="String">
  A string representation.
</ResponseField>

## Examples

### for valid geometry

```sql theme={"system"}
SELECT ST_IsValidReason(ST_GeomFromWKT('POLYGON ((100 100, 100 300, 300 300, 300 100, 100 100))')) as validity_info
```

```
Valid Geometry
```

### for invalid geometries

```sql theme={"system"}
SELECT gid, ST_IsValidReason(geom) as validity_info
FROM Geometry_table
WHERE ST_IsValid(geom) = false
ORDER BY gid
```

```
gid  |                  validity_info
-----+----------------------------------------------------
5330 | Self-intersection at or near point (32.0, 5.0, NaN)
5340 | Self-intersection at or near point (42.0, 5.0, NaN)
5350 | Self-intersection at or near point (52.0, 5.0, NaN)

```
