Ramda’s R.propIs() answers a yes/no question: does this property on an object match that constructor? You pass a constructor, a property name string, then an object. You get back a Boolean. Under the hood Ramda reads obj[name] and calls R.is — so R.propIs(Number, 'x', obj) is the same idea as R.is(Number, obj.x). It is not value equality: that is Relation cousin R.propEq, which uses R.equals. It is not a custom predicate: that is Logic cousin R.propSatisfies. Need a constructor on a bare value? That is Type cousin R.is. Need a string tag? That is Type cousin R.type. Missing, null, or undefined at the property name all fail the constructor check. Previous helper is R.isNotNil. Next is R.type.
The official sample is the whole idea. {x: 1, y: 2} passes for Number at 'x'. {x: 'foo'} and {} fail. Previous helper is R.isNotNil. Next is R.type.
Syntax
Call R.propIs. Start with this line.
Ramda
R.propIs(type, name, obj)
Call
What it does
R.propIs(type, name, obj)
Primary signature.
R.propIs(...)
Call the type helper.
Prefer import { propIs } from "ramda" when you want a named import.
Library declarations
Ramda
R.propIs(type, name, obj)
Parameters
Parameter
Description
type
Required. Constructor. The constructor to test against, such as Number, String, or Array.
name
Required. String. The property name on obj to read and test.
obj
Required. Object. The object whose property is checked.
Return Value
Return Value
Description
Boolean
true if the property at name on obj is an instance of type (via R.is), otherwise false.
Ramda Examples
📚 Getting Started
The official Ramda samples in one snippet, then the same check written with R.is manually.
Example 1 — Official Samples
Every docs line in one list. Constructor, property name, object in — Boolean back.
Both pass for Number 1. Only propIs still passes when the value is a number but propEq wanted the string '1'. Pick propEq for exact value match; pick propIs for constructor shape.
Example 4 — Missing or Wrong Property
Absent x, wrong type at x, or empty object — all false.
R.propIs(Number, 'x') waits for the object. filter keeps rows whose x is a Number. Same idea as list.filter(obj => R.is(Number, obj.x)).
Compatibility
Browser Support
R.propIs() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.16.0+ · Any JS runtime
Ramda.js R.propIs()
Load Ramda 0.16.0 or later via CDN or npm, then call R.propIs with constructor, name, and object. No extra browser API is required.
100%With Ramda 0.16.0+
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
R.propIs()Universal
Bottom line: Safe in any project that includes Ramda 0.16.0 or later. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node. These labs use [email protected], which includes the helper.
Frequently Asked Questions
R.propIs(type, name, obj) returns true when the property at name on obj is an instance of type, using R.is internally. Type: Type → String → Object → Boolean. Parameters: type (constructor), name (property name string), obj (object). Returns Boolean. Arity 3, curried. Added in v0.16.0.
R.propIs(Number, 'x', {x: 1, y: 2}) is true. R.propIs(Number, 'x', {x: 'foo'}) is false. R.propIs(Number, 'x', {}) is false.
R.is(ctor, val) tests a value directly. R.propIs(ctor, name, obj) reads obj[name] and runs the same constructor check. propIs(Number, 'x', obj) is the same idea as R.is(Number, obj.x).
propEq checks value equality via R.equals. propIs checks constructor membership via R.is. R.propEq(1, 'x', {x: 1}) is true, and so is R.propIs(Number, 'x', {x: 1}). R.propEq('1', 'x', {x: 1}) is false while the number 1 still passes propIs. In [email protected] the order is value first: R.propEq(val, name, obj).
R.propIs(Number, 'x', {}) is false because undefined is not a Number. A string at x is also false. Missing, null, undefined, or wrong constructor all fail.
No. R.propIs is a stable Ramda Type helper from v0.16.0. It is not deprecated, experimental, or non-standard.