From ef2d8d14a0179ae49eeab695610f0579a1287c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 18 May 2017 16:32:05 +0200 Subject: [PATCH] Added PillarServer.validator_for_resource() This makes it possible to perform Cerberus validation on documents. --- pillar/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pillar/__init__.py b/pillar/__init__.py index 17a4372e..e2a3b7df 100644 --- a/pillar/__init__.py +++ b/pillar/__init__.py @@ -618,6 +618,11 @@ class PillarServer(Eve): yield ctx + def validator_for_resource(self, resource_name: str) -> custom_field_validation.ValidateCustomFields: + schema = self.config['DOMAIN'][resource_name]['schema'] + validator = self.validator(schema, resource_name) + return validator + def _get_current_app(): """Returns the current application."""