rheactor-value-objects
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -32,4 +32,4 @@ 'use strict' | ||
DomainValue.Type = t.irreducible('DomainValue', (x) => x instanceof DomainValue) | ||
DomainValue.Type = t.irreducible('DomainValue', (x) => x.constructor.name === DomainValue.name) | ||
module.exports = DomainValue |
@@ -29,4 +29,4 @@ 'use strict' | ||
EmailValue.Type = t.irreducible('EmailValue', (x) => x instanceof EmailValue) | ||
EmailValue.Type = t.irreducible('EmailValue', (x) => x.constructor.name === EmailValue.name) | ||
module.exports = EmailValue |
@@ -43,3 +43,3 @@ { | ||
}, | ||
"version": "1.5.0" | ||
"version": "1.5.1" | ||
} |
@@ -14,4 +14,22 @@ # rheactor-value-objects | ||
## Common API | ||
### .Type() | ||
This method exposes a [tcomb](https://github.com/gcanti/tcomb) type validation base on the **name of the type**. | ||
Note that instanceof can't be used because having this check will return false, because the application using | ||
the value-objects package will create an instance that Node.js thinks to be from a different location that the | ||
one referenced in this package's `uri.js` | ||
# app.js | ||
const URIValue = require('rheactor-value-objects/uri') | ||
let u = new URIValue(…) | ||
URIValue.Type(u) // will fail | ||
# uri.js | ||
URIValue.Type = t.irreducible('URIValue', (x) => x instanceof URIValue) | ||
## TODO | ||
- Replace HAPI Joi validation with tcomb validation |
@@ -29,4 +29,4 @@ 'use strict' | ||
SlugValue.Type = t.irreducible('SlugValue', (x) => x instanceof SlugValue) | ||
SlugValue.Type = t.irreducible('SlugValue', (x) => x.constructor.name === SlugValue.name) | ||
module.exports = SlugValue |
@@ -45,4 +45,4 @@ 'use strict' | ||
TimeOfDayValue.Type = t.irreducible('TimeOfDayValueValue', (x) => x instanceof TimeOfDayValue) | ||
TimeOfDayValue.Type = t.irreducible('TimeOfDayValueValue', (x) => x.constructor.name === TimeOfDayValue.name) | ||
module.exports = TimeOfDayValue |
@@ -38,4 +38,4 @@ 'use strict' | ||
TimestampValue.Type = t.irreducible('TimestampValue', (x) => x instanceof TimestampValue) | ||
TimestampValue.Type = t.irreducible('TimestampValue', (x) => x.constructor.name === TimestampValue.name) | ||
module.exports = TimestampValue |
@@ -28,4 +28,4 @@ 'use strict' | ||
URIValue.Type = t.irreducible('URIValue', (x) => x instanceof URIValue) | ||
URIValue.Type = t.irreducible('URIValue', (x) => x.constructor.name === URIValue.name) | ||
module.exports = URIValue |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23772
35