@gnandretta Currently there is no way to show an error text for invalid additional signup fields.
Perhaps the validator function can pass a callback function where if there's an error, the message can be passed through the first parameter like so:
var options = {
additionalSignUpFields: [{
name: "address",
placeholder: "enter your address",
validator: function(address, cb) {
if (address.length > 10) cb();
cb("Error: Address must be greater than 10 chars");
}
}]
}
Or maybe the validator can just be returned a string if there's an error:
var options = {
additionalSignUpFields: [{
name: "address",
placeholder: "enter your address",
validator: function(address) {
if (address.length < 10) { return "Error: Address must be greater than 10 chars" }
}
}]
}
What do you think?
This is included on 10.0.0-rc.2. Following your example, you'll use it like this:
validator: function(address) {
return {
valid: address.length > 10, // required
hint: "Error: Address must be greater than 10 chars" // optional
}
@gnandretta
But it can use only pure functions, isn't it?
I mean what if I need to make a request to the server first and check whether the nickname is free?
Or any other asynchronous validation?
Version 10.11.0 still doesn't support callbacks for custom field validators. Is there a reason not to support this?
Most helpful comment
@gnandretta
But it can use only pure functions, isn't it?
I mean what if I need to make a request to the server first and check whether the nickname is free?
Or any other asynchronous validation?