@@ -5111,39 +5111,42 @@ export function isMaxProperties(maxProperties: number, annotations?: Annotations
51115111}
51125112
51135113/**
5114- * Validates that an object contains exactly the specified number of properties.
5114+ * Validates that an object contains between `minimum` and `maximum` properties (inclusive) .
51155115 * This includes both string and symbol keys when counting properties.
51165116 *
51175117 * **JSON Schema**
51185118 *
5119- * This check corresponds to both `minProperties` and `maxProperties`
5120- * constraints in JSON Schema, both set to the same value .
5119+ * This check corresponds to `minProperties` and `maxProperties`
5120+ * constraints in JSON Schema.
51215121 *
51225122 * **Arbitrary**
51235123 *
5124- * When generating test data with fast-check, this applies both `minLength` and
5124+ * When generating test data with fast-check, this applies `minLength` and
51255125 * `maxLength` constraints to the array of entries that is generated before
5126- * being converted to an object, ensuring the resulting object has exactly the
5127- * required number of properties.
5126+ * being converted to an object.
51285127 *
51295128 * @category Object checks
51305129 * @since 4.0.0
51315130 */
5132- export function isPropertiesLength ( length : number , annotations ?: Annotations . Filter ) {
5133- length = Math . max ( 0 , Math . floor ( length ) )
5131+ export function isPropertiesLengthBetween ( minimum : number , maximum : number , annotations ?: Annotations . Filter ) {
5132+ minimum = Math . max ( 0 , Math . floor ( minimum ) )
5133+ maximum = Math . max ( 0 , Math . floor ( maximum ) )
51345134 return makeFilter < object > (
5135- ( input ) => Reflect . ownKeys ( input ) . length === length ,
5135+ ( input ) => Reflect . ownKeys ( input ) . length >= minimum && Reflect . ownKeys ( input ) . length <= maximum ,
51365136 {
5137- expected : `a value with exactly ${ length === 1 ? "1 entry" : `${ length } entries` } ` ,
5137+ expected : minimum === maximum
5138+ ? `a value with exactly ${ minimum === 1 ? "1 entry" : `${ minimum } entries` } `
5139+ : `a value with between ${ minimum } and ${ maximum } entries` ,
51385140 meta : {
5139- _tag : "isPropertiesLength" ,
5140- length
5141+ _tag : "isPropertiesLengthBetween" ,
5142+ minimum,
5143+ maximum
51415144 } ,
51425145 [ AST . STRUCTURAL_ANNOTATION_KEY ] : true ,
51435146 toArbitraryConstraint : {
51445147 array : {
5145- minLength : length ,
5146- maxLength : length
5148+ minLength : minimum ,
5149+ maxLength : maximum
51475150 }
51485151 } ,
51495152 ...annotations
@@ -9018,9 +9021,10 @@ export declare namespace Annotations {
90189021 readonly _tag : "isMaxProperties"
90199022 readonly maxProperties : number
90209023 }
9021- readonly isPropertiesLength : {
9022- readonly _tag : "isPropertiesLength"
9023- readonly length : number
9024+ readonly isPropertiesLengthBetween : {
9025+ readonly _tag : "isPropertiesLengthBetween"
9026+ readonly minimum : number
9027+ readonly maximum : number
90249028 }
90259029 readonly isPropertyNames : {
90269030 readonly _tag : "isPropertyNames"
0 commit comments