typs.js
// checks if obj.length respects the given constraints (good for any array-like object)
checks if obj.length respects the given constraints (good for any array-like object)
checks if obj . length respects the given constraints ( good for any array - like object )
len ({min, max, exact}) {
		const param_type = typs().notNil().integer().positive();
		if (typs(min).isnt(param_type) && typs(max).isnt(param_type) && typs(exact).isnt(param_type)) {
			throw new Error('typs().len() expects at least one parameter to be a positive integer');
		}
		min = parseInt(min);
		max = parseInt(max);
		exact = parseInt(exact);
		if (min > max) throw new Error('typs().len() expects ordered bounds');
		return this.hasLength().add((obj) => {
			return (typs(min).is(param_type) ? obj.length >= min : true)
					&& (typs(max).is(param_type) ? obj.length <= max : true)
					&& (typs(exact).is(param_type) ? obj.length === exact : true)
		});
	}
len ( { min , max , exact } ) { const param_type = typs ( ) . notNil ( ) . integer ( ) . positive ( ) ; if ( typs ( min ) . isnt ( param_type ) && typs ( max ) . isnt ( param_type ) && typs ( exact ) . isnt ( param_type ) ) { throw new Error ( 'typs().len() expects at least one parameter to be a positive integer' ) ; } min = parseInt ( min ) ; max = parseInt ( max ) ; exact = parseInt ( exact ) ; if ( min > max ) throw new Error ( 'typs().len() expects ordered bounds' ) ; return this . hasLength ( ) . add ( ( obj ) => { return ( typs ( min ) . is ( param_type ) ? obj . length >= min : true ) && ( typs ( max ) . is ( param_type ) ? obj . length <= max : true ) && ( typs ( exact ) . is ( param_type ) ? obj . length === exact : true ) } ) ; }
checks if obj.length respects the given constraints (good for any array-like object)
checks if obj . length respects the given constraints ( good for any array - like object )