Have a helper function that builds a little signal holding a "fields"'s value and other stuff.
==>> the value should be validated using owl's validation schemas
function buildField(params = {}) {
const field = signal(params.value ?? null);
if (params.validation) {
field.required = params.required ?? true;
field.isValid = computed(() => validateType(field(), params.validation).length === 0)
} else {
field.isValid = () => true;
}
return field;
}
with concrete usage:
myField = buildField({ validation: t.string().optional(), required: false, value: "diamond" })
In this example we could have guessed the field was not required because the optional(undefined) already holds that information
Currently, the optionalSymbol is not exported, rightly so, but in user space there is no way to tell if the validator makes the value required or not
Maybe set a readonly flag on the validator ?
Have a helper function that builds a little signal holding a "fields"'s value and other stuff.
==>> the value should be validated using owl's validation schemas
with concrete usage:
In this example we could have guessed the field was not required because the optional(undefined) already holds that information
Currently, the optionalSymbol is not exported, rightly so, but in user space there is no way to tell if the validator makes the value required or not
Maybe set a readonly flag on the validator ?