> ## 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_IsValidDetail

Returns a row, containing a boolean `valid` stating if a geometry is valid, a string `reason` stating why it is invalid and a geometry `location` pointing out where it is invalid.

This function is a combination of [ST\_IsValid](/reference/wherobots-db/geometry-data/validation/ST_IsValid) and [ST\_IsValidReason](/reference/wherobots-db/geometry-data/validation/ST_IsValidReason).

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_IsValidDetail/ST_IsValidDetail.svg?fit=max&auto=format&n=fqh3gPDE0J25Lra_&q=85&s=020e208c2aa7ee04266d186154b0c2d5" alt="ST_IsValidDetail" width="400" height="130" data-path="images/sql-functions/ST_IsValidDetail/ST_IsValidDetail.svg" />

## Signatures

```sql theme={"system"}
ST_IsValidDetail(geom: Geometry)
```

```sql theme={"system"}
ST_IsValidDetail(geom: Geometry, flag: Integer)
```

## Parameters

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

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

## Return type

<ResponseField type="Struct<valid: Boolean, reason: String, location: Geometry>">
  A struct containing the result fields.
</ResponseField>

## Example

```sql theme={"system"}
SELECT ST_IsValidDetail(ST_GeomFromWKT('POLYGON ((30 10, 40 40, 20 40, 30 10, 10 20, 30 10))'))
```

```
+-----+---------------------------------------------------------+-------------+
|valid|reason                                                   |location     |
+-----+---------------------------------------------------------+-------------+
|false|Ring Self-intersection at or near point (30.0, 10.0, NaN)|POINT (30 10)|
+-----+---------------------------------------------------------+-------------+
```
