# openui5-validator

> An OpenUI5 library to validate fields

Latest version **1.0.0** (published 2023-12-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install openui5-validator
pnpm add openui5-validator
yarn add openui5-validator
bun add openui5-validator
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; has provenance.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-12-05 |
| First published | 2017-08-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 568.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 20 |
| Author | Mauricio Lauffer |
| Maintainers | mauriciolauffer |
| Keywords | openui5, sapui5, ui5, ui5lab, validate, validator, validation |

## Links

- npm: https://www.npmjs.com/package/openui5-validator
- Repository: https://github.com/mauriciolauffer/openui5-validator
- Homepage: https://github.com/mauriciolauffer/openui5-validator#readme
- Issues: https://github.com/mauriciolauffer/openui5-validator/issues
- npm.io page: https://npm.io/package/openui5-validator

## Dependencies (1)

- [ajv](https://npm.io/package/ajv.md) ^6.12.6

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-12-05
- 0.1.19 — 2022-04-26
- 0.1.18 — 2021-03-07
- 0.1.17 — 2020-10-16
- 0.1.16 — 2020-07-24
- 0.1.15 — 2020-04-09
- 0.1.14 — 2019-12-16
- 0.1.13 — 2019-12-12
- 0.1.12 — 2019-04-07
- 0.1.10 — 2018-11-14
- 0.1.9 — 2018-10-30
- 0.1.8 — 2018-09-12
- 0.1.7 — 2018-09-12
- 0.1.6 — 2018-07-26
- 0.1.5 — 2018-02-27
- … 6 more at https://npm.io/package/openui5-validator/versions

## README

# openui5-validator

[![npm](https://img.shields.io/npm/v/openui5-validator)](https://www.npmjs.com/package/openui5-validator) [![test](https://github.com/mauriciolauffer/openui5-validator/actions/workflows/test.yml/badge.svg)](https://github.com/mauriciolauffer/openui5-validator/actions/workflows/test.yml)

An OpenUI5 library to validate fields.

This library uses Ajv, a JSON schema validator. All validation keywords available in Ajv can be used.

## JSON Schema and Ajv

For any references, please follow

* [JSON schema specification](http://json-schema.org/)
* [Ajv documentation](https://github.com/epoberezkin/ajv)

Ajv Options: <https://github.com/epoberezkin/ajv#options>

Ajv Keywords: <https://github.com/epoberezkin/ajv#validation-keywords>

## Demo

You can check out a live demo here:

<https://mauriciolauffer.github.io/openui5-validator/demo/webapp/index.html>

![Demo Screenshot](./openui5-validator.png)

## Project Structure

* demo - Library's live demo
* dist - Distribution folder which contains the library ready to use
* src  - Development folder
* test - Testing framework for the library

## Getting started

### Installation

Install openui5-validator as an npm module

```sh
$ npm install openui5-validator
```

### Configure manifest.json

Add the library to *sap.ui5/dependencies/libs* and set its path in *sap.ui5/resourceRoots* in your manifest.json file, as follows:

```json
{
  "sap.ui5": {
    "dependencies": {
      "libs": {
        "openui5.validator": {}
      }
    },
    "resourceRoots": {
      "openui5.validator": "./FOLDER_WHERE_YOU_PLACED_THE_LIBRARY/openui5/validator/"
    }
  }
}
```

### How to use

Import openui5-validator to your UI5 controller using *sap.ui.require*:

```javascript
sap.ui.require([
  'openui5/validator/Validator'
], function (Validator) {
  const validationSchema = {
    properties: {
      email: { //UI5 control ID
        type: 'string',
        format: 'email',
        minLength: 3 //required
      },
      salary: { //UI5 control ID
        type: 'number',
        minimum: 0,
        maximum: 9999999
      },
      birthdate: { //UI5 control ID
        format: 'date'
      }
    }
  };

  const validator = new Validator(this.getView(), validationSchema);
  if (validator.validate()) {
    console.log('Valid!');
  } else {
    console.log('Invalid! Errors...');
    console.dir(validator.getErrors());
  }
});
```

## Config Parameters

| Name | Type | Default| Description
| :---- | :------------------- | :---- | :---------  |
| view | sap.ui.core.mvc.View | null | UI5 view which contains the fields to be validated.
| schema | object | null | JSON schema used for validation
| opt | object | null | Parameters to initialize Ajv

## Author

Mauricio Lauffer

* LinkedIn: [https://www.linkedin.com/in/mauriciolauffer](https://www.linkedin.com/in/mauriciolauffer)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

---
_Source: https://npm.io/package/openui5-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
