mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
String type must be strict.
It makes sense to coerce from more general -> more specific data types. eg. string -> int, etc. But coercing the other way is problematic in the case of chaining because the more general type will swallow the specific type. eg. Setting `false` on type: [‘string’, ‘boolean’] will coerce the boolean to a string, and will never allow the value to be a boolean.
This commit is contained in:
@@ -667,12 +667,10 @@ Config.addSchemaEnforcers
|
||||
throw new Error("Validation failed at #{keyPath}, #{JSON.stringify(value)} must be a boolean or the string 'true' or 'false'")
|
||||
|
||||
'string':
|
||||
coerce: (keyPath, value, schema) ->
|
||||
switch typeof value
|
||||
when 'number', 'string'
|
||||
value.toString()
|
||||
else
|
||||
throw new Error("Validation failed at #{keyPath}, #{JSON.stringify(value)} must be a string or number")
|
||||
validate: (keyPath, value, schema) ->
|
||||
unless typeof value is 'string'
|
||||
throw new Error("Validation failed at #{keyPath}, #{JSON.stringify(value)} must be a string")
|
||||
value
|
||||
|
||||
'null':
|
||||
# null sort of isnt supported. It will just unset in this case
|
||||
|
||||
Reference in New Issue
Block a user