# hasShape

Takes an object of validators defining the possible *shape* of an object and returns a new function that reports whether the received objects matches that shape or not.

```javascript
import hasShape form 'deep-waters/hasShape';
import isString form 'deep-waters/isString';
import isNumber form 'deep-waters/isNumber';

const isUser = hasShape({
    name: isString,
    age: isNumber,
}); 

isUser({ name: 'Antonio Rù', age: 33 }); // → true
isUser({ foo: 'bar' }); // → false
isUser({ name: 'Antonio Rù', age: 33, meta: { privacy: true } }); // → true
```

{% hint style="warning" %}
The created validator **isUser** only makes sure the received object has all the defined keys and each key matches the defined validation. \
It does not check on properties not defined by the shape, meaning it will return true even if the object has additional properties.
{% endhint %}

{% hint style="success" %}
hasShape could be easily used to define nested objects:
{% endhint %}

```javascript
import hasShape form 'deep-waters/hasShape';
import isString form 'deep-waters/isString';
import isNumber form 'deep-waters/isNumber';
import isBoolean from 'deep-waters/isBoolean';

const isUser = hasShape({
    name: isString,
    age: isNumber,
    meta: hasShape({
        privacy: isBoolean,
    })
}); 
```
