Lodash _.conformsTo() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Checks if object conforms to source by invoking each predicate in source with the matching property value from object. Returns true only if every predicate passes. Part of Lodash Lang since 4.14.0 (stable — not deprecated). Note: equivalent to _.conforms(source) when that function is applied to object.

Pass the value you want to inspect or convert. Read the return type carefully before you use the result.

Syntax

Call _.conformsTo. Start with this line.

Lodash
_.conformsTo(object, source)
CallWhat it does
_.conformsTo(object, source)Primary signature.
_.conformsTo(value)Check, compare, clone, or convert a value.

Prefer import conformsTo from "lodash/conformsTo" when you want a smaller bundle.

Library declarations
Lodash
_.conformsTo(object, source)

Parameters

ParameterDescription
objectRequired. Object to inspect
sourceRequired. Object of property predicates to conform to

Return Value

Return ValueDescription
*true if object conforms, else false

Lodash Examples

Example 1 — Official: Predicate Passes or Fails

Run one predicate on a matching property.

Lodash
var object = { a: 1, b: 2 };

console.log(_.conformsTo(object, {
  b: function (n) { return n > 1; }
})); // true

console.log(_.conformsTo(object, {
  b: function (n) { return n > 2; }
})); // false
Try It Yourself

How It Works

  1. Source key. Only b is listed, so only object.b is tested.
  2. Pass. 2 > 1 → predicate truthy → true.
  3. Fail. 2 > 2 → predicate falsy → false.
  4. Tip. Change the predicate, not the object shape, to express rules.

Example 2 — Multiple Predicates (All Must Pass)

Every source key must succeed — one failure fails the whole check.

Lodash
var user = { age: 21, active: true };

var ok = _.conformsTo(user, {
  age: function (n) { return n >= 18; },
  active: function (v) { return v === true; }
});

console.log(ok); // true
Try It Yourself

How It Works

  1. Age. 21 >= 18 → pass.
  2. Active. true === true → pass.
  3. AND logic. Both predicates must pass for true.
  4. Use. Readable guard clauses for request bodies or config objects.

Example 3 — Extra Object Keys Are Ignored

Only keys listed on source are checked.

Lodash
var object = { a: 1, b: 2, c: 99 };

console.log(_.conformsTo(object, {
  a: function (n) { return n === 1; }
})); // true — c is never tested
Try It Yourself

How It Works

  1. Source keys. Only a appears in the predicate map.
  2. Pass. object.a === 1 → true.
  3. Ignored. b and c are not validated.
  4. Rule. Add a predicate for every property you care about.

Example 4 — Missing Key Passes undefined

A missing property becomes undefined inside the predicate.

Lodash
var object = { a: 1 };

console.log(_.conformsTo(object, {
  b: function (n) { return n > 0; }
})); // false — b is undefined

console.log(_.conformsTo(object, {
  b: function (n) { return n === undefined; }
})); // true
Try It Yourself

How It Works

  1. Missing. object.b is undefined.
  2. Fail. undefined > 0 is falsy → false.
  3. Pass. An explicit n === undefined check can succeed.
  4. Guard. Decide whether absence should fail or be allowed.

Example 5 — conformsTo vs isMatch

Use predicates for dynamic rules; use isMatch for plain value partials.

Lodash
var object = { a: 1, b: 2 };

console.log(_.isMatch(object, { b: 2 })); // true

console.log(_.conformsTo(object, {
  b: function (n) { return n > 1; }
})); // true
Try It Yourself

How It Works

  1. isMatch. Compares against a plain partial — b must equal 2.
  2. conformsTo. Runs a function — any b > 1 is enough.
  3. Pick. Exact values → isMatch; ranges and types → conformsTo.
  4. Reuse. Need a filter predicate? Prefer _.conforms.

Browser & Runtime Support

_.conformsTo is a Lodash 4.x Lang helper (since 4.14.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native engines have no built-in predicate-map checker by this name.

✓ Stable · Lodash 4.14.0+

_.conformsTo()

Available in [email protected] full builds and the lodash/conformsTo modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.conformsTo Lodash 4.14.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import conformsTo from "lodash/conformsTo" for smaller builds. Not a native browser API — load Lodash first.

Frequently Asked Questions

_.conformsTo(object, source) checks whether object conforms to source by calling each predicate in source with the matching property value from object. Returns true only if every predicate passes.
No. It only reads values and runs predicates.
Lodash reads object[key], which is undefined when the key is missing. Your predicate must handle undefined if that case is possible.
isMatch compares against plain values or a partial object. conformsTo expects predicate functions in source for dynamic checks (greater-than, type tests, and so on).
conformsTo(object, source) is equivalent to applying _.conforms(source) to object — conforms returns a predicate function; conformsTo runs the check immediately.
Use import conformsTo from "lodash/conformsTo" or require("lodash/conformsTo") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.conformsTo.

Next: _.eq()

Compare two values with SameValueZero semantics.

_.eq() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful