Skip to content

Commit

Permalink
➕ Added static methods from and fromArray
Browse files Browse the repository at this point in the history
➕ Added configuration from function
  • Loading branch information
r37r0m0d3l committed Apr 3, 2020
1 parent 148a9a4 commit 779de21
Show file tree
Hide file tree
Showing 40 changed files with 288 additions and 38 deletions.
3 changes: 2 additions & 1 deletion docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- [Importing](/en/importing.md)
- [Creating Instance](/en/creating_instance.md)
- API
- [Configuration](/en/configuration.md)
- [Configuration Object](/en/configuration_object.md)
- [Configuration Function](/en/configuration_function.md)
- [Data Manipulation](/en/data_manipulation.md)
- [Static Methods](/en/static_methods.md)
- Functions
Expand Down
3 changes: 2 additions & 1 deletion docs/en/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- [Importing](/en/importing.md)
- [Creating Instance](/en/creating_instance.md)
- API
- [Configuration](/en/configuration.md)
- [Configuration Object](/en/configuration_object.md)
- [Configuration Function](/en/configuration_function.md)
- [Data Manipulation](/en/data_manipulation.md)
- [Static Methods](/en/static_methods.md)
- Functions
Expand Down
4 changes: 3 additions & 1 deletion docs/en/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

---

## 1.4.0 Apr 03, 2020
## 1.4.0 Apr 04, 2020

- ➕ Added static methods `from` and `fromArray`

- ➕ Added configuration from function

---

## 1.3.12 Mar 30, 2020
Expand Down
80 changes: 80 additions & 0 deletions docs/en/configuration_function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Configuration Function

---

## Configuration function with minimal parameters

```js
const serializer = new Vicis(function (model) {
return {
castToBoolean: model.property_01.boolean,
castToFlag: model.property_02.flag,
castToInteger: model.property_03.integer,
castToNumeric: model.property_04.numeric,
castToString: model.property_05.string,
castToJSON: model.property_06.json,
mustBeDefined: model.property_07.defined,
mustBeWithValue: model.property_08.required,
defaultValue: model.property_09.default("no value"),
transformedValue: model.property_10.transform((value) => value++),
valueToBeReplaced: model.property_11.replace("Override value"),
justValue: "You can put here anything",
};
});

serializer.data(modelFromDatabase).toJSON();
```

```json
{
"castToBoolean": true,
"castToFlag": false,
"castToInteger": 12345,
"castToNumeric": 123.456,
"castToString": "Title",
"castToJSON": { "a": 1 },
"mustBeDefined": "I'm defined",
"mustBeWithValue": "Has value",
"defaultValue": "no value",
"transformedValue": 2,
"justValue": "You can put here anything"
}
```

---

## Chained example

```js
const serializer = new Vicis(function (model) {
return {
id: model.id.required.integer,
title: model.title.defined.string,
active: true,
rating: model.rating.numeric,
tested: model.tested.default(false),
};
});

const modelFromDatabase = {
id: "12345",
title: "",
active: "maybe",
rating: "3.5",
tested: undefined,
};

serializer.data(modelFromDatabase).toJSON();
```

```json
{
"id": 12345,
"title": "",
"active": true,
"rating": 3.5,
"tested": false
}
```

---
4 changes: 2 additions & 2 deletions docs/en/configuration.md → docs/en/configuration_object.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Configuration
# Configuration Object

---

## Configuration object
## Configuration object properties

[Cast](/en/cast.md) [Defaults](/en/defaults.md) [Defined](/en/defined.md) [Exclude](/en/exclude.md) [Omit](/en/omit.md) [Order](/en/order.md) [Pick](/en/pick.md) [Rename](/en/rename.md) [Replace](/en/replace.md) [Required](/en/required.md) [Transform](/en/transform.md)

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
42 changes: 21 additions & 21 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta charset="UTF-8" />
<title>Vicis - Presentation and transformation layer for data output in RESTful APIs.</title>
Expand All @@ -9,24 +9,24 @@
name="viewport"
content="width=device-width, user-scalable=yes, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0"
/>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png" />
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png" />
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png" />
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png" />
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png" />
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png" />
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="shortcut icon" href="/icons/favicon.ico" type="image/x-icon" />
<link rel="icon" href="/icons/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" sizes="57x57" href="/icons/apple-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="60x60" href="/icons/apple-icon-60x60.png" />
<link rel="apple-touch-icon" sizes="72x72" href="/icons/apple-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="76x76" href="/icons/apple-icon-76x76.png" />
<link rel="apple-touch-icon" sizes="114x114" href="/icons/apple-icon-114x114.png" />
<link rel="apple-touch-icon" sizes="120x120" href="/icons/apple-icon-120x120.png" />
<link rel="apple-touch-icon" sizes="144x144" href="/icons/apple-icon-144x144.png" />
<link rel="apple-touch-icon" sizes="152x152" href="/icons/apple-icon-152x152.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-icon-180x180.png" />
<link rel="icon" type="image/png" sizes="192x192" href="/icons/android-icon-192x192.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="96x96" href="/icons/favicon-96x96.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png" />
<link rel="manifest" href="/manifest.json" />
<meta name="msapplication-TileColor" content="#ffffff" />
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png" />
<meta name="msapplication-TileImage" content="/icons/ms-icon-144x144.png" />
<meta name="theme-color" content="#ffffff" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css" />
<style>
Expand All @@ -43,14 +43,14 @@
}
:root {
--base-font-size: 18px;
--base-font-weight: bold;
--base-line-height: 1.05;
--code-font-weight: bold;
/*--base-font-weight: bold;*/
--base-line-height: 1.2;
/*--code-font-weight: bold;*/
--content-max-width: 90%;
--sidebar-nav-link-border-color--active: #000;
--sidebar-nav-link-color--active: #000;
--sidebar-nav-link-color: #666666;
--sidebar-nav-link-font-weight: bold;
/*--sidebar-nav-link-font-weight: bold;*/
--sidebar-nav-link-text-decoration-color: #000;
--sidebar-width: 370px;
}
Expand Down
14 changes: 7 additions & 7 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@
"homepage_url": "https://vicis.js.org",
"icons": [
{
"src": "/android-icon-36x36.png",
"src": "/icons/android-icon-36x36.png",
"sizes": "36x36",
"type": "image/png",
"density": "0.75"
},
{
"src": "/android-icon-48x48.png",
"src": "/icons/android-icon-48x48.png",
"sizes": "48x48",
"type": "image/png",
"density": "1.0"
},
{
"src": "/android-icon-72x72.png",
"src": "/icons/android-icon-72x72.png",
"sizes": "72x72",
"type": "image/png",
"density": "1.5"
},
{
"src": "/android-icon-96x96.png",
"src": "/icons/android-icon-96x96.png",
"sizes": "96x96",
"type": "image/png",
"density": "2.0"
},
{
"src": "/android-icon-144x144.png",
"src": "/icons/android-icon-144x144.png",
"sizes": "144x144",
"type": "image/png",
"density": "3.0"
},
{
"src": "/android-icon-192x192.png",
"src": "/icons/android-icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"density": "4.0"
Expand All @@ -48,5 +48,5 @@
"keyword": "npm"
},
"short_name": "Vicis",
"version": "1.0.14"
"version": "1.4.0"
}
3 changes: 2 additions & 1 deletion docs/ru/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- [Импортирование](/ru/importing.md)
- [Создание Экземпляра](/ru/creating_instance.md)
- Интерфейс
- [Конфигурация](/ru/configuration.md)
- [Конфигурация Объектом](/ru/configuration_object.md)
- [Конфигурация Функцией](/ru/configuration_function.md)
- [Работа с Данными](/ru/data_manipulation.md)
- [Статические Методы](/ru/static_methods.md)
- Функции
Expand Down
4 changes: 3 additions & 1 deletion docs/ru/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

---

## 1.4.0 Апр 03, 2020
## 1.4.0 Апр 04, 2020

- ➕ Добавлены статические методы `from` и` fromArray`

- ➕ Добавлена конфигурация из функции

---

## 1.3.12 Мар 24, 2020
Expand Down
80 changes: 80 additions & 0 deletions docs/ru/configuration_function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Конфигурация Функцией

---

## Конфигурация функцией с минимальными параметрами

```js
const serializer = new Vicis(function (model) {
return {
castToBoolean: model.property_01.boolean,
castToFlag: model.property_02.flag,
castToInteger: model.property_03.integer,
castToNumeric: model.property_04.numeric,
castToString: model.property_05.string,
castToJSON: model.property_06.json,
mustBeDefined: model.property_07.defined,
mustBeWithValue: model.property_08.required,
defaultValue: model.property_09.default("no value"),
transformedValue: model.property_10.transform((value) => value++),
valueToBeReplaced: model.property_11.replace("Override value"),
justValue: "You can put here anything",
};
});

serializer.data(modelFromDatabase).toJSON();
```

```json
{
"castToBoolean": true,
"castToFlag": false,
"castToInteger": 12345,
"castToNumeric": 123.456,
"castToString": "Title",
"castToJSON": { "a": 1 },
"mustBeDefined": "I'm defined",
"mustBeWithValue": "Has value",
"defaultValue": "no value",
"transformedValue": 2,
"justValue": "You can put here anything"
}
```

---

## Пример вызовов цепочкой

```js
const serializer = new Vicis(function (model) {
return {
id: model.id.required.integer,
title: model.title.defined.string,
active: true,
rating: model.rating.numeric,
tested: model.tested.default(false),
};
});

const modelFromDatabase = {
id: "12345",
title: "",
active: "maybe",
rating: "3.5",
tested: undefined,
};

serializer.data(modelFromDatabase).toJSON();
```

```json
{
"id": 12345,
"title": "",
"active": true,
"rating": 3.5,
"tested": false
}
```

---
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Конфигурация
# Конфигурация Объектом

---

Expand Down
3 changes: 2 additions & 1 deletion docs/ua/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- [Імпорт](/ua/importing.md)
- [Створення Екземпляра](/ua/creating_instance.md)
- Інтерфейс
- [Конфігурація](/ua/configuration.md)
- [Конфігурація Об'єктом](/ua/configuration_object.md)
- [Конфігурація Функцією](/ua/configuration_function.md)
- [Робота з Даними](/ua/data_manipulation.md)
- [Статичні Методи](/ua/static_methods.md)
- Функції
Expand Down
4 changes: 3 additions & 1 deletion docs/ua/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

---

## 1.4.0 Апр 03, 2020
## 1.4.0 Апр 04, 2020

- ➕ Додані статичні методи `from` і` fromArray`

- ➕ Додана конфігурація функцією

---

## 1.3.12 Бер 24, 2020
Expand Down
Loading

0 comments on commit 779de21

Please sign in to comment.