@@ -1505,6 +1505,30 @@ def multi_overlap(self, func, n_outputs, **kwargs):
15051505 from .utils import multi_overlap
15061506 return multi_overlap (self ._obj , func , n_outputs , ** kwargs )
15071507
1508+ # ---- Diagnostics ----
1509+
1510+ def validate (self , * , raise_on_error = False ):
1511+ """Check this DataArray against the xarray-spatial input contract.
1512+
1513+ Returns a :class:`~xrspatial.validate.ValidationReport` listing
1514+ every contract violation as an error (a spatial op will fail) or
1515+ a warning (behavior degrades), each with a suggested fix. The
1516+ report is truthy when there are no error-level issues, so
1517+ ``if not da.xrs.validate(): ...`` reads naturally.
1518+
1519+ Parameters
1520+ ----------
1521+ raise_on_error : bool, default False
1522+ If True, raise :class:`~xrspatial.validate.XrsContractError`
1523+ when any error-level issue is found instead of only
1524+ recording it in the report.
1525+ """
1526+ from .validate import validate
1527+ report = validate (self ._obj )
1528+ if raise_on_error :
1529+ report .raise_if_errors ()
1530+ return report
1531+
15081532
15091533@xr .register_dataset_accessor ("xrs" )
15101534class XrsSpatialDatasetAccessor :
@@ -2116,6 +2140,28 @@ def rechunk_no_shuffle(self, **kwargs):
21162140 from .utils import rechunk_no_shuffle
21172141 return rechunk_no_shuffle (self ._obj , ** kwargs )
21182142
2143+ # ---- Diagnostics ----
2144+
2145+ def validate (self , * , raise_on_error = False ):
2146+ """Check each data variable against the xarray-spatial contract.
2147+
2148+ Returns a
2149+ :class:`~xrspatial.validate.DatasetValidationReport` holding a
2150+ per-variable :class:`~xrspatial.validate.ValidationReport`. The
2151+ report is truthy when every variable is compliant.
2152+
2153+ Parameters
2154+ ----------
2155+ raise_on_error : bool, default False
2156+ If True, raise :class:`~xrspatial.validate.XrsContractError`
2157+ when any variable has an error-level issue.
2158+ """
2159+ from .validate import validate_dataset
2160+ report = validate_dataset (self ._obj )
2161+ if raise_on_error :
2162+ report .raise_if_errors ()
2163+ return report
2164+
21192165
21202166# ---------------------------------------------------------------------------
21212167# Surface standalone-function docstrings on accessor methods so that, e.g.,
0 commit comments