mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	
							parent
							
								
									7d46dcbb21
								
							
						
					
					
						commit
						4f3a94cb86
					
				| @ -8,7 +8,12 @@ const nameSchema = joi.object().keys({ name: nameType }); | ||||
| const constraintSchema = joi.object().keys({ | ||||
|     contextName: joi.string(), | ||||
|     operator: joi.string(), | ||||
|     values: joi.array().items(joi.string()), | ||||
|     values: joi.array().items( | ||||
|         joi | ||||
|             .string() | ||||
|             .min(1) | ||||
|             .max(100), | ||||
|     ), | ||||
| }); | ||||
| 
 | ||||
| const strategiesSchema = joi.object().keys({ | ||||
|  | ||||
| @ -172,3 +172,55 @@ test('should keep constraints', t => { | ||||
|     t.deepEqual(value, toggle); | ||||
|     t.falsy(error); | ||||
| }); | ||||
| 
 | ||||
| test('should not accept empty constraint values', t => { | ||||
|     const toggle = { | ||||
|         name: 'app.constraints.empty.value', | ||||
|         type: 'release', | ||||
|         enabled: false, | ||||
|         stale: false, | ||||
|         strategies: [ | ||||
|             { | ||||
|                 name: 'default', | ||||
|                 constraints: [ | ||||
|                     { | ||||
|                         contextName: 'environment', | ||||
|                         operator: 'IN', | ||||
|                         values: [''], | ||||
|                     }, | ||||
|                 ], | ||||
|             }, | ||||
|         ], | ||||
|     }; | ||||
| 
 | ||||
|     const { error } = featureShema.validate(toggle); | ||||
|     t.deepEqual( | ||||
|         error.details[0].message, | ||||
|         '"strategies[0].constraints[0].values[0]" is not allowed to be empty', | ||||
|     ); | ||||
| }); | ||||
| 
 | ||||
| test('should not accept empty list of constraint values', t => { | ||||
|     const toggle = { | ||||
|         name: 'app.constraints.empty.value.list', | ||||
|         type: 'release', | ||||
|         enabled: false, | ||||
|         stale: false, | ||||
|         strategies: [ | ||||
|             { | ||||
|                 name: 'default', | ||||
|                 constraints: [ | ||||
|                     { | ||||
|                         contextName: 'environment', | ||||
|                         operator: 'IN', | ||||
|                         values: [], | ||||
|                     }, | ||||
|                 ], | ||||
|             }, | ||||
|         ], | ||||
|     }; | ||||
| 
 | ||||
|     const { value, error } = featureShema.validate(toggle); | ||||
|     t.deepEqual(value, toggle); | ||||
|     t.falsy(error); | ||||
| }); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user