Schema questions

I’ve got a couple of Schema questions.

  1. How do people currently support numeric range inputs in get_schema()? There’s no int or float input, nor slider. Do you do a text input and perform some sort of validation? If so, how do you provide response back to the user?

  2. How do you test schema configuration before publishing?

  1. Had to do text input and do:
if x.isdigit():
    x = int(x)
else:
    print("I'm not a digit!")

Not sure if there’s a better way. Ref: string  |  Bazel

  1. I just save a bunch of different configs and use those as regression tests. If the tests don’t work as intended, that’s when I know something went wrong with my change. Again tell me if there’s a different/easier way.
1 Like

If the range of values is small you could use a schema.Dropdown control with all the possible options.

The other option is to do what you said and use two text inputs. Retrieve and validate the numbers in the main function, if anything is wrong you can render a screen (return render.Root…) with an error message.

For testing, just use the pixlet serve command and use the simulator, it let’s you tweak the configuration like the mobile app.

1 Like

Thanks for the answers.

I’ve got a third Schema question. I would think a Generated schema section would appear in the order in which it’s defined in the schema, but instead it seems to be appended to the end. Is there any way to group the generated schema with it’s associated triggering options?

And a fourth! I decided to create a “Quick” option, where one of the options is “Advanced.” This reveals the rest of the settings. That’s fine, but one of the settings has another schema.Generated field, which now displays “Unsupported type: generated” where the additional field data would go. Does this mean that Schema does not support more than one Generated field type?

Is there any way to group the generated schema with it’s associated triggering options?

Nope, it always appends the generated fields to the end :frowning:

Does this mean that Schema does not support more than one Generated field type?

You can have more than one Generated field in the Schema, but they need to be independent of each other. They need to be “siblings” in the schema. In your case, you’re trying to make one Generated field return another one, and this is not possible :frowning:

Well that’s a bummer. Okay. Thanks for the quick reply. I’ll figure something out. :slight_smile: