mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Back to getSchema
This commit is contained in:
@@ -438,7 +438,7 @@ describe "Config", ->
|
||||
|
||||
atom.config.setSchema('foo.bar.anInt', schema)
|
||||
expect(atom.config.get("foo.bar.anInt")).toBe 12
|
||||
expect(atom.config.schemaForKeyPath('foo.bar.anInt')).toEqual
|
||||
expect(atom.config.getSchema('foo.bar.anInt')).toEqual
|
||||
type: 'integer'
|
||||
default: 12
|
||||
|
||||
@@ -465,7 +465,7 @@ describe "Config", ->
|
||||
type: 'integer'
|
||||
default: 12
|
||||
|
||||
describe '.schemaForKeyPath(keyPath)', ->
|
||||
describe '.getSchema(keyPath)', ->
|
||||
schema =
|
||||
type: 'object'
|
||||
properties:
|
||||
@@ -475,14 +475,14 @@ describe "Config", ->
|
||||
|
||||
atom.config.setSchema('foo.bar', schema)
|
||||
|
||||
expect(atom.config.schemaForKeyPath('foo.bar')).toEqual
|
||||
expect(atom.config.getSchema('foo.bar')).toEqual
|
||||
type: 'object'
|
||||
properties:
|
||||
anInt:
|
||||
type: 'integer'
|
||||
default: 12
|
||||
|
||||
expect(atom.config.schemaForKeyPath('foo.bar.anInt')).toEqual
|
||||
expect(atom.config.getSchema('foo.bar.anInt')).toEqual
|
||||
type: 'integer'
|
||||
default: 12
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ class Config
|
||||
isDefault: (keyPath) ->
|
||||
not _.valueForKeyPath(@settings, keyPath)?
|
||||
|
||||
schemaForKeyPath: (keyPath) ->
|
||||
getSchema: (keyPath) ->
|
||||
keys = keyPath.split('.')
|
||||
schema = @schema
|
||||
for key in keys
|
||||
@@ -395,7 +395,7 @@ class Config
|
||||
defaults
|
||||
|
||||
scrubValue: (keyPath, value) ->
|
||||
value = @constructor.executeSchemaValidators(value, schema) if schema = @schemaForKeyPath(keyPath)
|
||||
value = @constructor.executeSchemaValidators(value, schema) if schema = @getSchema(keyPath)
|
||||
value
|
||||
|
||||
Config.addSchemaValidators
|
||||
|
||||
Reference in New Issue
Block a user