commodo-fields-int
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "commodo-fields-int", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A int field for Commodo composable models.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -6,3 +6,2 @@ # commodo-fields-int | ||
[![](https://img.shields.io/npm/v/commodo-fields-int.svg)](https://www.npmjs.com/package/commodo-fields-int) | ||
![](https://img.shields.io/npm/types/commodo-fields-int.svg) | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
@@ -12,3 +11,3 @@ [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) | ||
A int field for Commodo composeable models. | ||
A simple integer field, used with the [Commodo `withFields`](https://github.com/webiny/commodo/tree/master/packages/fields) higher order function. | ||
@@ -35,7 +34,28 @@ ## Install | ||
name: string(), | ||
year: int() | ||
}) | ||
age: int(), // Use it to store a single integer value. | ||
topYears: int({ list: true }) // Or use it to store a list of integer values. | ||
// Other fields you might need... | ||
}), | ||
// Other higher order functions (HOFs) you might need... | ||
)(); | ||
const company = new Company(); | ||
company.name = "Acme Corporation"; | ||
// The int field can only accepts integers. | ||
company.age = 17; | ||
company.topYears = [2000, 2005, 2010]; | ||
// The following will throw the WithFieldsError error. | ||
company.age = "17"; | ||
company.topYears = [2000, "2005", 2010]; | ||
``` | ||
Note: alternatively, you could've also used the [`populate`](https://github.com/webiny/commodo/tree/master/packages/fields#populatedata-object-void) method to assign the data: | ||
```javascript | ||
const company = new Company(); | ||
company.populate = { age: 17, topYears: [2000, 2005, 2010] }; | ||
``` | ||
## Contributors | ||
@@ -42,0 +62,0 @@ |
17325
69