mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-11-04 12:42:21 +00:00 
			
		
		
		
	Helps us validate lists that contain a bunch of values and see if it contains a desired list of values
		
			
				
	
	
		
			34 lines
		
	
	
	
		
			729 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
	
		
			729 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
{lib}: let
 | 
						|
  inherit (lib.lists) elem all;
 | 
						|
in {
 | 
						|
  /*
 | 
						|
  Checks if all values are present in the list.
 | 
						|
 | 
						|
  Type:
 | 
						|
    listContainsValues :: { list :: [a], values :: [a] } -> Bool
 | 
						|
 | 
						|
  Arguments:
 | 
						|
    list - A list of elements.
 | 
						|
    values - A list of values to check for presence in the list.
 | 
						|
 | 
						|
  Returns:
 | 
						|
    True if all values are present in the list, otherwise False.
 | 
						|
 | 
						|
  Example:
 | 
						|
    ```nix
 | 
						|
    listContainsValues { list = [1 2 3]; values = [2 3]; }
 | 
						|
    => True
 | 
						|
 | 
						|
    listContainsValues { list = [1 2 3]; values = [2 4]; }
 | 
						|
    => False
 | 
						|
    ```
 | 
						|
  */
 | 
						|
  listContainsValues = {
 | 
						|
    list,
 | 
						|
    values,
 | 
						|
  }: let
 | 
						|
    # Check if all values are present in the list
 | 
						|
    containsValue = value: elem value list;
 | 
						|
  in
 | 
						|
    all containsValue values;
 | 
						|
}
 |