@@ -89,30 +89,38 @@ $_swappable-properties: text-align;
89
89
/// Internal validation function to ensure the user overrides variables with
90
90
/// accepted values.
91
91
///
92
- /// @param {List|Map} list-or-map - The list or map to validate against
92
+ /// @since 6.4.0 Added support for strings so that single item lists can be used.
93
+ /// @param {List|Map|String} options - The list or map of available options.
94
+ /// This can also be a single item list.
93
95
/// @param {String|Number} key-or-value - Either the map key or list value to
94
96
/// check if exists
95
97
/// @param {String} error-message - The additional error message to display
96
98
/// @returns {any} the value from the list or map
97
- @function validate ($list-or-map , $key-or-value , $error-message ) {
98
- $type : meta .type-of ($list-or-map );
99
+ @function validate ($options , $key-or-value , $error-message ) {
100
+ $options : if (
101
+ meta .type-of ($options ) == string ,
102
+ list .append ((), $options ),
103
+ $options
104
+ );
105
+
106
+ $type : meta .type-of ($options );
99
107
$is-map : $type == map;
100
108
$is-list : $type == list ;
101
109
102
110
@if $disable-validation {
103
- @return if ($is-list , $key-or-value , map .get ($list-or-map , $key-or-value ));
111
+ @return if ($is-list , $key-or-value , map .get ($options , $key-or-value ));
104
112
}
105
113
106
114
@if not $is-map and not $is-list {
107
- @error ' Unable to validate anything except for lists and maps at this time. Received: #{$list-or-map } . ' ;
115
+ @error " Unable to validate anything except for lists and maps at this time. Received: ' #{$options } '. " ;
108
116
}
109
117
110
- $choices : if ($is-map , map .keys ($list-or-map ), $list-or-map );
118
+ $choices : if ($is-map , map .keys ($options ), $options );
111
119
@if not list .index ($choices , $key-or-value ) {
112
120
@error " Invalid #{$error-message } : '#{$key-or-value } '. Choose one of: #{$choices } " ;
113
121
}
114
122
115
- @return if ($is-list , $key-or-value , map .get ($list-or-map , $key-or-value ));
123
+ @return if ($is-list , $key-or-value , map .get ($options , $key-or-value ));
116
124
}
117
125
118
126
/// Used to get a custom property variable name.
0 commit comments