Framework

- About
- Guides
- Community
- API
- Code
- Download

# Kanso API Documentation

Index | View on single page

## fieldset

Functions for dealing with collections of fields. Used by both the types and forms modules.

### createDefaults(fields, req)

Returns a hierachy of default values for a given set of Field objects

#### Parameters

fields | Object |
req | Object | the request object to pass to default_value functions

Returns: Object

### validateField(field, doc, value, raw, path)

Validate a specific field, returning all validation errors as an array with each error's field property prefixed by the current path.

#### Parameters

field | Field |
doc | Object |
value |  |
raw |  |
path | Array |

Returns: Array

### validate(fields, doc, values, raw, path, extra)

Validates an object containing fields or other sub-objects, iterating over each property and recursing through sub-objects to find all Fields.

Returns an array of validation errors, each with a field property set to the path of the field which caused the error.

#### Parameters

fields | Object |
doc | Object |
values | Object |
raw | Object |
path | Array |
extra | Boolean | whether to allow extra values not covered by a field

Returns: Array

### authField(f, nDoc, oDoc, nVal, oVal, user, path)

Authorize a specific field, returning all permissions errors as an array with each error's field property prefixed by the current path.

#### Parameters

f | Field | field object
nDoc | Object | new document
oDoc | Object | old document
nVal |  | new field value
oVal |  | old field value
user | Object | user context object
path | Array | current path

Returns: Array

### authFieldSet(f, nDoc, oDoc, nVal, oVal, user, path)

Authorizes an object containing fields or other sub-objects, iterating over each property and recursing through sub-objects to find all Fields.

Returns an array of permissions errors, each with a field property set to the path of the field which caused the error.

#### Parameters

f | Field | field object
nDoc | Object | new document
oDoc | Object | old document
nVal |  | new field value
oVal |  | old field value
user | Object | user context object
path | Array | current path
extra | Boolean | whether to raise an error on additional fields

Returns: Array