# Hypersync proof type criteria When a user selects a [proof type](/hypersync-sdk/sdk-006-proof-types) in a Hypersync app, they may need to provide criteria values to parameterize the proof. Hyperproof and the Hypersync app work together to display form fields for collecting this information. The app provides criteria metadata, which defines how each field appears in Hyperproof—such as the control type and label text. Criteria metadata is often built incrementally. The app typically returns metadata for the first field, then receives the user’s input and responds with metadata for the next field. This continues until all required criteria have been provided. Criteria fields can also span multiple pages in the Hypersync wizard. For example, a proof type with seven criteria fields might display four fields on the first page and the remaining three on the next. The Hypersync SDK uses criteria provider components to surface criteria metadata and criteria values to Hyperproof. The SDK also includes a `JsonCriteriaProvider` component that can be used to easily surface criteria metadata using a declarative `criteriaFields.json` as the source. This makes it possible to define and configure criteria fields with no code. For more advanced scenarios, the SDK's `ICriteriaProvider` interface allows you to build your own criteria provider. > **Note**: If you're defining your proof types with JSON, there is no need to create your own criteria provider. For these proof types, the SDK has built-in support for `JsonProofProvider` and the `criteriaFields.json` file. ## No-Code criteria provider The `JsonProofProvider` class in the SDK makes it easy to define criteria metadata without writing code. To use this class, begin by creating a `criteriaFields.json` file in the `/json` directory. The file should have the following format: ``` { "$schema": "https://cdn.jsdelivr.net/gh/Hyperproof/hypersync-sdk/schema/criteriaFields.schema.json", "groupName": { "type": "select", "property": "group", "label": "Group Name", "isRequired": true, "dataSet": "groups", "valueProperty": "id", "labelProperty": "groupName", "fixedValues": [ { "value": "{{constants.ID_ALL}}", "label": "All Groups" } ] } ... } ``` In this example, `groupName` is a criterion field that allows the user to select a group by name in the Hyperproof UI. There should be one entry in this file for every criteria field to be shown to the user. For more information on `criteriaFields.json`, see [Criteria fields JSON format](/hypersync-sdk/sdk-014-criteria-fields-json). ## Custom criteria provider In advanced scenarios, you may need to implement a custom criteria provider. The SDK exposes the `ICriteriaProvider` interface for this purpose, which defines three methods: 1. `generateProofCategoryField` – Returns a proof category field used to filter proof types by category. For apps with only a few proof types, this method can return null. 2. `generateCriteriaFields` – Called as the user creates or edits a Hypersync. It returns an `ICriteriaMetadata` object containing the fields the user must configure, along with defaults for the Hypersync name, execution frequency, and versioning behavior. This method is invoked iteratively during configuration. 3. `generateProofCriteria` – Called at sync time to format the configured criteria for inclusion in the generated proof. It typically applies transformations and performs lookups as needed. ``` class MyCriteriaProvider implements ICriteriaProvider{ generateProofCategoryField( criteriaValues: HypersyncCriteria, tokenContext: TokenContext ): Promise { // TODO: Return an initialized ICriteriaField to be used as the proof // category if categorization is desired. Otherwise return null. } async generateCriteriaFields( proofCriteria: IProofCriterionRef[], criteriaValues: HypersyncCriteria, tokenContext: TokenContext, pages: ICriteriaPage[] ): Promise { // TODO: Generate an ICriteriaMetdata instance containing the metadata for // the fields the user needs to configure, as well as defaults for the Hyperysnc // name, frequency of execution, and versioning behavior. } async generateProofCriteria( proofCriteria: IProofCriterionRef[], criteriaValues: HypersyncCriteria, tokenContext: TokenContext ): Promise { // TODO: Return a set of criterion values that can be rendered in a proof document } } ``` Once you have implemented your custom `ICriteriaProvider`, override the `createCriteriaProvider` method on `HypersyncApp` to return your new class: ``` public async createCriteriaProvider( dataSource: IDataSource ): Promise { return new MyCriteriaProvider(dataSource); } ```