> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/selphid-documentos/propiedades/rules.md).

# rules

## Details

**Attribute:** `rules`

**Type:** `RulesSchema`

**Default value:** `{}`

### RuleName

| Member           | Value            | Description                          |
| ---------------- | ---------------- | ------------------------------------ |
| `FirstName`      | `firstName`      | Holder's first name in the document. |
| `LastName`       | `lastName`       | Holder's last name.                  |
| `Gender`         | `gender`         | Holder's gender.                     |
| `Nationality`    | `nationality`    | Holder's nationality.                |
| `PlaceOfBirth`   | `placeOfBirth`   | Place of birth.                      |
| `DateOfBirth`    | `dateOfBirth`    | Date of birth.                       |
| `DateOfIssue`    | `dateOfIssue`    | Document issue date.                 |
| `DateOfExpiry`   | `dateOfExpiry`   | Document expiration date.            |
| `DocumentNumber` | `documentNumber` | Document number.                     |

### RuleTypes

| Member        | Value         | Description                                             |
| ------------- | ------------- | ------------------------------------------------------- |
| `EqualTo`     | `equalTo`     | The extracted value must be equal to the specified one. |
| `Contains`    | `contains`    | The extracted value must contain the specified one.     |
| `Required`    | `required`    | The field is required (`value: true`).                  |
| `MaxLength`   | `maxLength`   | Maximum field length (number).                          |
| `MinLength`   | `minLength`   | Minimum field length (number).                          |
| `EqualLength` | `equalLength` | Exact length of the extracted value (number).           |

### EngineDocumentTypes

| Member     | Value      | Description        |
| ---------- | ---------- | ------------------ |
| `ID`       | `ID`       | Identity document. |
| `DL`       | `DL`       | Driver's license.  |
| `PASSPORT` | `PASSPORT` | Passport.          |

## Morphology

```typescript
import { EngineDocumentTypes, RuleName, RuleTypes } from '@facephi/selphid-web-component';

selphid.rules = {
  HN: [
    { key: RuleName.FirstName, rule: RuleTypes.Required, value: true },
    { key: RuleName.LastName, rule: RuleTypes.Required, value: true },
    {
      key: RuleName.Gender,
      rule: RuleTypes.Required,
      value: true,
      documentTypes: [EngineDocumentTypes.ID, EngineDocumentTypes.PASSPORT],
    },
    {
      key: RuleName.DateOfBirth,
      rule: RuleTypes.MinLength,
      value: 6,
      documentTypes: [EngineDocumentTypes.ID],
      documentSide: 0,
    },
  ],
};
```

## Description

Rule schema by country code (ISO) applied before extraction in `facephi-selphid-widget`. Each entry in the array defines the field (`key`), the rule type (`rule`), the comparison value (`value`) and, optionally, the document types (`documentTypes`) and the document side (`documentSide`: `0` front, `1` back).

### Considerations

JS property only (no HTML attribute). If it is not defined, no rule is applied to the capture process.

Each rule follows the type `RuleSchema`:

```typescript
{
  key: string;
  rule: RuleTypes;
  value: string | number | boolean;
  documentTypes?: EngineDocumentTypes[];
  documentSide?: number;
}
```

***

## Example

```jsx
import { EngineDocumentTypes, RuleName, RuleTypes } from '@facephi/selphid-web-component';

<facephi-selphid-widget
    rules={{
        HN: [
            { key: RuleName.FirstName, rule: RuleTypes.Required, value: true },
            { key: RuleName.LastName, rule: RuleTypes.Required, value: true },
            {
                key: RuleName.Gender,
                rule: RuleTypes.Required,
                value: true,
                documentTypes: [EngineDocumentTypes.ID, EngineDocumentTypes.PASSPORT],
            },
        ],
    }}
/>
```
