Structure
SettingsValidator
public struct SettingsValidator<S: Validatable & Codable>
Helper structure that performs settings validation
This can be used inside of your policy main.swift
file
to simplify the registration of the validate_settings
guest function:
let settingsValidator = SettingsValidator<MyPolicySettings>()
wapc.registerFunction(name: "validate_settings", fn: settingsValidator.validate)
Parameters
Name | Type | Description |
---|---|---|
S | Your policy settings class |
Initializers
init()
public init()
Methods
validate(payload:)
public func validate(payload: String) -> String
This method instantiates the generic settings class defined at construction
time using the provided payload. Then it invokes the validate()
method
provided by it and build a SettingsValidationResponse
object
Parameters
Name | Type | Description |
---|---|---|
payload | String |
A JSON dictionary holding the settings |
Returns
A SettingsValidationResponse
serialized to JSON