@@ -89,30 +89,38 @@ $_swappable-properties: text-align;
8989/// Internal validation function to ensure the user overrides variables with
9090/// accepted values.
9191///
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.
9395/// @param {String|Number} key-or-value - Either the map key or list value to
9496/// check if exists
9597/// @param {String} error-message - The additional error message to display
9698/// @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 );
99107 $is-map : $type == map;
100108 $is-list : $type == list ;
101109
102110 @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 ));
104112 }
105113
106114 @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 } '. " ;
108116 }
109117
110- $choices : if ($is-map , map .keys ($list-or-map ), $list-or-map );
118+ $choices : if ($is-map , map .keys ($options ), $options );
111119 @if not list .index ($choices , $key-or-value ) {
112120 @error " Invalid #{$error-message } : '#{$key-or-value } '. Choose one of: #{$choices } " ;
113121 }
114122
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 ));
116124}
117125
118126/// Used to get a custom property variable name.
0 commit comments