1 # is-data-descriptor [![NPM version](https://img.shields.io/npm/v/is-data-descriptor.svg)](https://www.npmjs.com/package/is-data-descriptor) [![Build Status](https://img.shields.io/travis/jonschlinkert/is-data-descriptor.svg)](https://travis-ci.org/jonschlinkert/is-data-descriptor)
3 > Returns true if a value has the characteristics of a valid JavaScript data descriptor.
7 Install with [npm](https://www.npmjs.com/):
10 $ npm i is-data-descriptor --save
16 var isDataDesc = require('is-data-descriptor');
21 `true` when the descriptor has valid properties with valid values.
24 // `value` can be anything
25 isDataDesc({value: 'foo'})
26 isDataDesc({value: function() {}})
27 isDataDesc({value: true})
31 `false` when not an object
42 `false` when the object has invalid properties
45 isDataDesc({value: 'foo', bar: 'baz'})
47 isDataDesc({value: 'foo', bar: 'baz'})
49 isDataDesc({value: 'foo', get: function(){}})
51 isDataDesc({get: function(){}, value: 'foo'})
55 `false` when a value is not the correct type
58 isDataDesc({value: 'foo', enumerable: 'foo'})
60 isDataDesc({value: 'foo', configurable: 'foo'})
62 isDataDesc({value: 'foo', writable: 'foo'})
68 The only valid data descriptor properties are the following:
70 * `configurable` (required)
71 * `enumerable` (required)
73 * `writable` (optional)
75 To be a valid data descriptor, either `value` or `writable` must be defined.
77 **Invalid properties**
79 A descriptor may have additional _invalid_ properties (an error will **not** be thrown).
84 Object.defineProperty(foo, 'bar', {
86 whatever: 'blah', // invalid, but doesn't cause an error
98 * [is-accessor-descriptor](https://www.npmjs.com/package/is-accessor-descriptor): Returns true if a value has the characteristics of a valid JavaScript accessor descriptor. | [homepage](https://github.com/jonschlinkert/is-accessor-descriptor)
99 * [is-descriptor](https://www.npmjs.com/package/is-descriptor): Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… [more](https://www.npmjs.com/package/is-descriptor) | [homepage](https://github.com/jonschlinkert/is-descriptor)
100 * [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject)
104 Install dev dependencies:
107 $ npm i -d && npm test
112 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-data-descriptor/issues/new).
118 * [github/jonschlinkert](https://github.com/jonschlinkert)
119 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
123 Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)
124 Released under the MIT license.
128 _This file was generated by [verb](https://github.com/verbose/verb) on December 28, 2015._