# SDK methods for Form Validation Basic

---

### `getField(fieldId)`

**Arguments:**

- `fieldId` (String): The identifier for the field you want to retrieve information for.

**Returns:**

- `FieldData`: An object containing field-related data.

**Description:**

This method retrieves information about a specific field identified by `fieldId`. The returned `FieldData` object includes the following properties:

- `id` (String): The field's identifier.
- `visibility` (Boolean): Indicates whether the field is currently visible.
- `value` (Any): The current value of the field.
- `basicValidationResult` (BasicValidationResult): The result of the basic validation for the field.
- `errorMsg` (String): An error message, if any, resulting from basic validation. If the field is valid, this property will be an empty string.

**Example:**

```js
const fieldData = getField('fieldId');
console.log(fieldData);
```

---

### `validateField(fieldId, value)`

**Arguments:**

- `fieldId` (String): The identifier for the field you want to validate.
- `value` (Any): The value you want to validate for the field.

**Returns:**

- `ValidationResult`: An object containing field validation related data.

**Description:**

This method performs basic validation and validation rule on the provided `value` for the field identified by `fieldId`. It returns a `ValidationResult`.

`ValidationResult` object, which includes the following properties:

- `isValid` (Boolean): Indicates whether the `value` is valid according to basic validation and validation rules.
- `isEmpty` (Boolean): Indicates whether the `value` is empty.
- `errorMessage` (String): An error message, if any, resulting from basic validation and validation rules. If the `value` is valid, this property will be an empty string.
- `basicValidation` (BasicValidationResult): basic validation result.
- `ruleResult`:(Array<RuleValidationResult>) An object indicating the result of the validation rules that specific for that field.

`BasicValidationResult` object, which includes the following properties:

- `isValid` (Boolean): Indicates whether the `value` is valid according to basic validation rules.
- `isEmpty` (Boolean): Indicates whether the `value` is empty.
- `errorMessage` (String): An error message, if any, resulting from basic validation. If the `value` is valid, this property will be an empty string.

**Example:**

```js
const validationResult = sdk.validateField('fieldId', 'exampleValue');
console.log(validationResult);
```

---

### `validateField(fieldId)`

**Arguments:**

- `fieldId` (String): The identifier for the field you want to validate and update the UI for.

**Returns:**

- `None`
<!-- - `Promise<ValidationResult>`: A promise that resolves to a `ValidationResult` object. -->

**Description:**

This method performs basic validation and validation rule on the filled `value` for the field identified by `fieldId`. It also updates the UI to display an error message based on the validation result.

 <!-- The method returns a promise that resolves to a `ValidationResult` object, which includes the following properties: -->

- `isValid` (Boolean): Indicates whether the `value` is valid according to basic validation rules.
- `isEmpty` (Boolean): Indicates whether the `value` is empty.
- `errorMessage` (String): An error message, if any, resulting from basic validation. If the `value` is valid, this property will be an empty string.

**Example:**

```js
sdk.validateField('fieldId')
  .then((validationResult) => {
    console.log(validationResult);
  })
  .catch((error) => {
    console.error('Validation and UI update failed:', error);
  });
```
