Publish: validate names as the user types

Rejects invalid characters and pops up a form hint explaining what
characters are allowed.
This commit is contained in:
Alex Liebowitz 2016-11-18 04:01:25 -05:00
parent 5af7916b20
commit e0d0c3f915

View file

@ -161,14 +161,19 @@ var PublishPage = React.createClass({
return; return;
} }
if (!lbry.nameIsValid(rawName, false)) {
this.refs.name.showAdvice('LBRY names must contain only letters, numbers and dashes.');
return;
}
this.setState({ this.setState({
rawName: rawName, rawName: rawName,
}); });
var name = lbry.formatName(rawName); var name = rawName.toLowerCase();
lbry.resolveName(name, (info) => { lbry.resolveName(name, (info) => {
if (name != lbry.formatName(this.refs.name.getValue())) { if (name != this.refs.name.getValue().toLowerCase()) {
// A new name has been typed already, so bail // A new name has been typed already, so bail
return; return;
} }