mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-08 16:19:17 +03:00
Support arrays
This commit is contained in:
parent
2526ba0efb
commit
409b5536e1
@ -602,3 +602,15 @@ describe "Config", ->
|
||||
nestedObject:
|
||||
nestedBool: true
|
||||
|
||||
describe 'when the value has an "array" type', ->
|
||||
beforeEach ->
|
||||
schema =
|
||||
type: 'array'
|
||||
default: [1, 2, 3]
|
||||
items:
|
||||
type: 'integer'
|
||||
atom.config.setSchema('foo.bar', schema)
|
||||
|
||||
it 'converts an array of strings to an array of ints', ->
|
||||
atom.config.set 'foo.bar', ['2', '3', '4']
|
||||
expect(atom.config.get('foo.bar')).toEqual [2, 3, 4]
|
||||
|
@ -427,8 +427,18 @@ Config.addTypeFilters
|
||||
value
|
||||
|
||||
'object':
|
||||
typeCheck: (value, schema) ->
|
||||
coercion: (value, schema) ->
|
||||
throw new Error() if typeof value isnt 'object'
|
||||
return value unless schema.properties?
|
||||
for prop, childSchema of schema.properties
|
||||
value[prop] = @executeTypeFilters(value[prop], childSchema) if prop of value
|
||||
value
|
||||
|
||||
'array':
|
||||
coercion: (value, schema) ->
|
||||
throw new Error() unless Array.isArray(value)
|
||||
itemSchema = schema.items
|
||||
if itemSchema?
|
||||
@executeTypeFilters(item, itemSchema) for item in value
|
||||
else
|
||||
value
|
||||
|
Loading…
Reference in New Issue
Block a user