Ejemplo n.º 1
0
        private bool InputIsInvalid(string input)
        {
            if (input.Length > Ean13.CheckedLength)
            {
                return(true);
            }

            if (input.Length == Ean13.CheckedLength && !Ean13.Check(input))
            {
                return(true);
            }

            return(input.ToCharArray().Any(_ => !char.IsDigit(_)));
        }
Ejemplo n.º 2
0
        private void OnTextChanged(object sender, TextChangedEventArgs e)
        {
            if (string.IsNullOrEmpty(e.NewTextValue))
            {
                return;
            }

            if (e.NewTextValue.Length > Ean13.CheckedLength ||
                e.NewTextValue.Length == Ean13.CheckedLength && !Ean13.Check(e.NewTextValue))
            {
                AssociatedObject.Text = e.OldTextValue;
                return;
            }

            if (e.NewTextValue.Length != Ean13.CheckedLength)
            {
                return;
            }

            Command?.Execute(e.NewTextValue);
        }