https://github.com/alexius-huang/manufacturer
JS Factory Pattern Implementation
https://github.com/alexius-huang/manufacturer
Last synced: 7 days ago
JSON representation
JS Factory Pattern Implementation
- Host: GitHub
- URL: https://github.com/alexius-huang/manufacturer
- Owner: Alexius-Huang
- Created: 2018-03-02T09:21:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-11T10:21:17.000Z (over 7 years ago)
- Last Synced: 2025-04-05T23:29:24.318Z (2 months ago)
- Language: JavaScript
- Size: 900 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Manufacturer
## A JavaScript Factory Pattern Implementation
[](https://travis-ci.org/Maxwell-Alexius/Manufacturer) [](https://codeclimate.com/github/Maxwell-Alexius/Manufacturer/maintainability)
```js
import Manufacturer from 'manufacturer';
const { Type } = Manufacturer;const Person =
Manufacturer
.define({
name: Type.String,
age: Type.Number.Positive.Integer.Between(18, 90),
married: Type.Boolean,
interest: Type.OneOf(['Eating', 'Coding', 'Sleeping'])
});const Product =
Manufacturer
.define({
name: Type.String,
price: Type.Number.Positive.Float.Between(0.01, 100),
produceDate: Type.Time.Format('YYYY-MM-DD'),
expirationDate: Type.Time.After(14, 'days', 'YYYY-MM-DD')
});const Store =
Manufacturer
.define({
name: Type.String,
category: Type.OneOf(['Food & Drinks', 'Electronics', 'Furniture']),
owner: Person,
products: Type.ArrayOf(Product)
});/* Create a new Store */
console.log(Store.create());
```