Skip to content

Repository files navigation

commodo-fields-float

Build StatusCovergrowth Statuscode style: prettierAll ContributorsPRs Welcome

A simple float field, used with the Commodo withFields higher order function.

Install

npm install --save commodo-fields-float

Or if you prefer yarn:

yarn add commodo-fields-float

Quick Example:

import{compose}from"ramda";import{withFields,string}from"@commodo/fields";import{float}from"commodo-fields-float";constCompany=compose(withFields({name: string(),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...)();constcompany=newCompany();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 method to assign the data:

constcompany=newCompany();company.populate={growth: 5.65,pastGrowths: [5.63,3.99,9.542,10]};

Contributors

Thanks goes to these wonderful people (emoji key):


Adrian Smijulj

💻📖💡👀⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

About

A simple float field, used with the Commodo "withFields" higher order function.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages