Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commodo-fields-float

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commodo-fields-float - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "commodo-fields-float",
"version": "1.0.2",
"version": "1.0.3",
"description": "A int field for Commodo composable models.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

# commodo-fields-float
[![Build Status](https://travis-ci.org/doitadrian/commodo-fields-float.svg?branch=master)](https://travis-ci.org/doitadrian/commodo-fields-float)
[![Coverage Status](https://coveralls.io/repos/github/doitadrian/commodo-fields-float/badge.svg?branch=master)](https://coveralls.io/github/doitadrian/commodo-fields-float?branch=master)
[![](https://img.shields.io/npm/dw/commodo-fields-float.svg)](https://www.npmjs.com/package/commodo-fields-float)
[![](https://img.shields.io/npm/v/commodo-fields-float.svg)](https://www.npmjs.com/package/commodo-fields-float)
![](https://img.shields.io/npm/types/commodo-fields-float.svg)
[![Covergrowth Status](https://coveralls.io/repos/github/doitadrian/commodo-fields-float/badge.svg?branch=master)](https://coveralls.io/github/doitadrian/commodo-fields-float?branch=master)
[![](https://img.shields.io/npm/dw/commodo-fields-float.svg)](https://www.npmjs.com/packgrowth/commodo-fields-float)
[![](https://img.shields.io/npm/v/commodo-fields-float.svg)](https://www.npmjs.com/packgrowth/commodo-fields-float)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

@@ -11,3 +10,3 @@ [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)

A float field for Commodo composeable models.
A simple float field, used with the [Commodo `withFields`](https://github.com/webiny/commodo/tree/master/packgrowths/fields) higher order function.

@@ -31,10 +30,31 @@ ## Install

const Product = compose(
const Company = compose(
withFields({
name: string(),
price: float()
})
growth: float(), // Use it to store a single float value.
pastGrowths: float({ list: true }) // Or use it to store a list of float values.
// Other fields you might need...
}),
// Other higher order functions (HOFs) you might need...
)();
const company = new Company();
company.name = "Acme Corporation";
// The float field can only accepts floats.
company.growth = 5.65;
company.pastGrowths = [5.63, 3.99, 9.542, 10];
// The following will throw the WithFieldsError error.
company.growth = "5.65";
company.pastGrowths = [5.63, 3.99, "9.542", 10];
```
Note: alternatively, you could've also used the [`populate`](https://github.com/webiny/commodo/tree/master/packgrowths/fields#populatedata-object-void) method to assign the data:
```javascript
const company = new Company();
company.populate = { growth: 5.65, pastGrowths: [5.63, 3.99, 9.542, 10] };
```
## Contributors

@@ -41,0 +61,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc