Include all options in enum error messages#2957
Conversation
|
Thanks @binste! Now the following returns the right error suggestions: import altair as alt
x_tu = alt.X().timeUnit('yearmonthdatehour')
alt.Chart().encode(x_tu)SchemaValidationError: 'yearmonthdatehour' is an invalid value for `timeUnit`:
'yearmonthdatehour' is not one of ['year', 'quarter', 'month', 'week', 'day', 'dayofyear', 'date', 'hours', 'minutes', 'seconds', 'milliseconds']
'yearmonthdatehour' is not one of ['utcyear', 'utcquarter', 'utcmonth', 'utcweek', 'utcday', 'utcdayofyear', 'utcdate', 'utchours', 'utcminutes', 'utcseconds', 'utcmilliseconds']
'yearmonthdatehour' is not one of ['yearquarter', 'yearquartermonth', 'yearmonth', 'yearmonthdate', 'yearmonthdatehours', 'yearmonthdatehoursminutes', 'yearmonthdatehoursminutesseconds', 'yearweek', 'yearweekday', 'yearweekdayhours', 'yearweekdayhoursminutes', 'yearweekdayhoursminutesseconds', 'yeardayofyear', 'quartermonth', 'monthdate', 'monthdatehours', 'monthdatehoursminutes', 'monthdatehoursminutesseconds', 'weekday', 'weeksdayhours', 'weekdayhoursminutes', 'weekdayhoursminutesseconds', 'dayhours', 'dayhoursminutes', 'dayhoursminutesseconds', 'hoursminutes', 'hoursminutesseconds', 'minutesseconds', 'secondsmilliseconds']
'yearmonthdatehour' is not one of ['utcyearquarter', 'utcyearquartermonth', 'utcyearmonth', 'utcyearmonthdate', 'utcyearmonthdatehours', 'utcyearmonthdatehoursminutes', 'utcyearmonthdatehoursminutesseconds', 'utcyearweek', 'utcyearweekday', 'utcyearweekdayhours', 'utcyearweekdayhoursminutes', 'utcyearweekdayhoursminutesseconds', 'utcyeardayofyear', 'utcquartermonth', 'utcmonthdate', 'utcmonthdatehours', 'utcmonthdatehoursminutes', 'utcmonthdatehoursminutesseconds', 'utcweekday', 'utcweeksdayhours', 'utcweekdayhoursminutes', 'utcweekdayhoursminutesseconds', 'utcdayhours', 'utcdayhoursminutes', 'utcdayhoursminutesseconds', 'utchoursminutes', 'utchoursminutesseconds', 'utcminutesseconds', 'utcsecondsmilliseconds']One question, maybe you now this directly, why isn't the following directly returning an error: x_tuX({
timeUnit: 'yearmonthdatehour'
})Is it because the encoding channel properties are only inferred based on the encoding channel in which it is defined? |
|
The main part where the schema is validated is when Some objects are already being validated when there instantiated by calling
|
|
Thanks for digging deep! So we are seeing the behavior introduced by #546. More clear now. In line with your comment here, #2850 (comment), maybe better to alias |

Fixes what @mattijn found in #2949 (comment). So far, for the error messages only the errors at the same leaf level of the "error tree" where considered. For errors which show that a value is not part of an enum, it seems to make sense to find and list all enums in leaves.