|
@ -3,8 +3,12 @@ import { keys } from './object.js'; |
|
|
export default function validateKeys ( object, allowedKeys ) { |
|
|
export default function validateKeys ( object, allowedKeys ) { |
|
|
const actualKeys = keys( object ); |
|
|
const actualKeys = keys( object ); |
|
|
|
|
|
|
|
|
for ( let key of actualKeys ) { |
|
|
let i = actualKeys.length; |
|
|
if ( allowedKeys.indexOf( key ) < 0 ) { |
|
|
|
|
|
|
|
|
while ( i-- ) { |
|
|
|
|
|
const key = actualKeys[i]; |
|
|
|
|
|
|
|
|
|
|
|
if ( allowedKeys.indexOf( key ) === -1 ) { |
|
|
return new Error( |
|
|
return new Error( |
|
|
`Unexpected key '${ key }' found, expected one of: ${ allowedKeys.join( ', ' ) }` |
|
|
`Unexpected key '${ key }' found, expected one of: ${ allowedKeys.join( ', ' ) }` |
|
|
); |
|
|
); |
|
|