first commit
This commit is contained in:
28
node_modules/stylelint/lib/utils/validateObjectWithProps.mjs
generated
vendored
Normal file
28
node_modules/stylelint/lib/utils/validateObjectWithProps.mjs
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { isPlainObject } from './validateTypes.mjs';
|
||||
|
||||
/**
|
||||
* Check whether the variable is an object and all its properties agree with the provided validator.
|
||||
*
|
||||
* @example
|
||||
* config = {
|
||||
* value1: 1,
|
||||
* value2: 2,
|
||||
* value3: 3,
|
||||
* };
|
||||
* validateObjectWithProps(isNumber)(config);
|
||||
* //=> true
|
||||
*
|
||||
* @param {(value: unknown) => boolean} validator
|
||||
* @returns {(value: unknown) => boolean}
|
||||
*/
|
||||
export default function validateObjectWithProps(validator) {
|
||||
return (value) => {
|
||||
if (!isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Object.values(value).every((item) => {
|
||||
return validator(item);
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user